This is explained here unicode-and-utf-8 <http://docs.julialang.org/en/stable/manual/strings/#unicode-and-utf-8>. You want to use `nextind`: name2="김아무개" name2[1] '김' nextind(name2,1) 4 name2[4] '아' name2[ nextind(name2,4) ] '무' name2[nextind(name2,nextind(name2,4))] '개'
On Friday, July 22, 2016 at 10:23:26 PM UTC-4, Joungmin Lee wrote: > > Hi, I've been dealing with some strings including asian characters. > > In case of indexing of ASCIIString, there's no problem. > But when dealing with a UTF8String, I could get only 1st and last > characters. > > > julia> name1="John Doe" > "John Doe" > > julia> name2="김아무개" > "김아무개" > > julia> name3="近藤雅子" > "近藤雅子" > > julia> name1[1] > 'J' > > julia> name1[2] > 'o' > > julia> name2[1] > '김' > > julia> name2[2] > ERROR: UnicodeError: invalid character index > in next at unicode/utf8.jl:65 > in getindex at strings/basic.jl:37 > > julia> name3[1] > '近' > > julia> name3[2] > ERROR: UnicodeError: invalid character index > in next at unicode/utf8.jl:65 > in getindex at strings/basic.jl:37 > > julia> name3[end] > '子' > > julia> name3[end-1] > ERROR: UnicodeError: invalid character index > in next at unicode/utf8.jl:65 > in getindex at strings/basic.jl:37 > julia> > > > Is this result a bug? Otherwise do I miss something? > > Joungmin > >
