-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorstrings"Strings!""Strings!"unicodeRelated to unicode characters and encodingsRelated to unicode characters and encodings
Description
I believe there's an issue with the implementation of iterate on the result of graphemes("π€¦πΌββοΈ").
The following works as expected:
julia> s = "π€¦πΌββοΈ"
"π€¦πΌ\u200dβοΈ"
julia> length(s) == 5
true
julia> [s[i] for i in eachindex(s)]
5-element Array{Char,1}:
'π€¦': Unicode U+1F926 (category So: Symbol, other)
'πΌ': Unicode U+1F3FC (category Sk: Symbol, modifier)
'\u200d': Unicode U+200D (category Cf: Other, format)
'β': Unicode U+2642 (category So: Symbol, other)
'οΈ': Unicode U+FE0F (category Mn: Mark, nonspacing)
julia> using Unicode
julia> length(graphemes(s)) == 1
trueHowever, this is the error I get when I try to collect the result of the Iterator in the latest stable release of Julia (v1.5.1).
julia> collect(graphemes(s))
ERROR: ArgumentError: destination has fewer elements than required
Stacktrace:
[1] copyto!(::Array{SubString{String},1}, ::Base.Unicode.GraphemeIterator{String}) at ./abstractarray.jl:734
[2] _collect at ./array.jl:630 [inlined]
[3] collect(::Base.Unicode.GraphemeIterator{String}) at ./array.jl:624
[4] top-level scope at REPL[5]:1The implementation of length appears to be correct, but I think there's a bug in the implementation of iterate:
julia> for (i, c) in enumerate(graphemes(s))
println(i, " ", c)
end
1 π€¦πΌβ
2 βοΈI believe the correct behavior in this case is to return just the first element. iterate seems to be returning the Symbol β as well.
simeonschaub and Nosfericansimeonschaub
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorstrings"Strings!""Strings!"unicodeRelated to unicode characters and encodingsRelated to unicode characters and encodings