Skip to content

Commit 9eda0a5

Browse files
committed
Fix bugs with convert function and LatinStr/_LatinStr in some cases
1 parent 266312c commit 9eda0a5

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ authors = ["ScottPJones <scottjones@alum.mit.edu>"]
44
keywords = ["Strings"]
55
license = "MIT"
66
uuid = "e79e7a6a-7bb1-5a4d-9d64-da657b06f53a"
7-
version = "1.1.0"
7+
version = "1.1.1"
88

99
[deps]
1010
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

src/latin.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#=
22
LatinStr/_LatinStr type (ISO Latin1 8-bit subset of Unicode)
33
4-
Copyright 2017 Gandalf Software, Inc., Scott P. Jones, and other contributors to the Julia language
4+
Copyright 2017-2022 Gandalf Software, Inc., Scott P. Jones,
5+
and other contributors to the Julia language
56
Licensed under MIT License, see LICENSE.md
67
Based in part on code for ASCIIString that used to be in Julia
78
=#
@@ -50,7 +51,7 @@ const LatinSubStr = SubString{<:Str{LatinCSE}}
5051
const _LatinSubStr = SubString{<:Str{_LatinCSE}}
5152

5253
_cpyconvert(::Type{C}, str) where {C} = Str(C, _copysub(str))::Str{C,Nothing,Nothing,Nothing}
53-
_cpysubset(::Type{_LatinCSE}, str) = Str(is_ascii(s) ? ASCIICSE : _LatinCSE, _copysub(s))
54+
_cpysubset(::Type{_LatinCSE}, str) = Str(is_ascii(str) ? ASCIICSE : _LatinCSE, _copysub(str))
5455

5556
convert(::Type{<:Str{LatinCSE}}, s::Str{LatinCSE}) = s
5657
convert(::Type{<:Str{LatinCSE}}, s::Str{ASCIICSE}) = _cpyconvert(LatinCSE, s)
@@ -167,7 +168,7 @@ end
167168

168169
function convert(::Type{<:Str{C}}, vec::Vector{CU}) where {C<:Latin_CSEs,CU<:CodeUnitTypes}
169170
# handle zero length string quickly
170-
(len = length(vec)) == 0 && return _empty_str(C)
171+
(len = length(vec)) == 0 && return empty_str(C)
171172
@preserve vec begin
172173
pnt = pointer(vec)
173174
# get number of bytes to allocate

test/convert.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Typos in Latin conversions
2+
3+
@test convert(StrBase._LatinStr, SubString(LatinStr("abc"))) == ASCIIStr("abc")
4+
@test convert(LatinStr, UInt8[]) == ""
5+
16
# issue #11551 (#11004,#10959)
27
function tstcvt(strUTF8::UTF8Str, strUTF16::UTF16Str, strUTF32::UTF32Str)
38
@test utf16(strUTF8) == strUTF16

0 commit comments

Comments
 (0)