Ai
21 Star 49 Fork 0

Gitee 极速下载/julia-language

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/JuliaLang/julia
克隆/下载
utf8.jl 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
Keno Fischer 提交于 2017-12-22 20:37 +08:00 . Change iteration protocol
# This file is a part of Julia. License is MIT: https://julialang.org/license
@testset "string indexing" begin
let str = "this is a test\xed\x80"
@test iterate(str, 15) == (reinterpret(Char, 0xed800000), 17)
@test_throws BoundsError getindex(str, 0:3)
@test_throws BoundsError getindex(str, 17:18)
@test_throws BoundsError getindex(str, 2:17)
@test_throws BoundsError getindex(str, 16:17)
@test string(Char(0x110000)) == "\xf4\x90\x80\x80"
end
end
@testset "string reverse" begin
@test reverse("") == ""
@test reverse("a") == "a"
@test reverse("abc") == "cba"
@test reverse("xyz\uff\u800\uffff\U10ffff") == "\U10ffff\uffff\u800\uffzyx"
for (s, r) in [
"xyz\xc1" => "\xc1zyx",
"xyz\xd0" => "\xd0zyx",
"xyz\xe0" => "\xe0zyx",
"xyz\xed\x80" => "\xed\x80zyx",
"xyz\xf0" => "\xf0zyx",
"xyz\xf0\x80" => "\xf0\x80zyx",
"xyz\xf0\x80\x80" => "\xf0\x80\x80zyx",
]
@test reverse(s) == r
end
end
@testset "string convert" begin
@test String(b"this is a test\xed\x80\x80") ==
"this is a test\xed\x80\x80" ==
"this is a test\ud000"
# Specifically check UTF-8 string whose lead byte is same as a surrogate
@test String(b"\xed\x9f\xbf") == "\xed\x9f\xbf" == "\ud7ff"
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/mirrors/julia-language.git
git@gitee.com:mirrors/julia-language.git
mirrors
julia-language
julia-language
master

搜索帮助