Skip to content

Commit b13e9d1

Browse files
committed
fix graphemes eltype for substrings (fixes #22693)
better grapheme-substring testset name test substring grapheme eltype
1 parent 5bc6b96 commit b13e9d1

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

base/strings/utf8proc.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ letter combined with an accent mark is a single grapheme.)
354354
graphemes(s::AbstractString) = GraphemeIterator{typeof(s)}(s)
355355

356356
eltype(::Type{GraphemeIterator{S}}) where {S} = SubString{S}
357+
eltype(::Type{GraphemeIterator{SubString{S}}}) where {S} = SubString{S}
357358

358359
function length(g::GraphemeIterator)
359360
c0 = Char(0x00ad) # soft hyphen (grapheme break always allowed after this)

test/unicode/utf8proc.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,9 @@ end
314314
@test repr(g) == "length-14 GraphemeIterator{String} for \"$str\""
315315
end
316316
end
317+
318+
@testset "#22693: substring graphemes" begin
319+
g = graphemes(SubString("123α56789", 1, 6))
320+
@test eltype(g) == SubString{String}
321+
@test collect(g) == ["1","2","3","α","5"]
322+
end

0 commit comments

Comments
 (0)