julia> s = "🛀🛀"

"🛀🛀"



julia> for i in 4:8

           substr = s[1:i]

           subbytes = convert(Vector{UInt8},substr)

           @show "----- 1:$i -----" substr subbytes length(subbytes)

       end

"----- 1:$(i) -----" = "----- 1:4 -----"

substr = "🛀"

subbytes = UInt8[0xf0,0x9f,0x9b,0x80]

length(subbytes) = 4

"----- 1:$(i) -----" = "----- 1:5 -----"

substr = "🛀🛀"

subbytes = UInt8[0xf0,0x9f,0x9b,0x80,0xf0,0x9f,0x9b,0x80]

length(subbytes) = 8

"----- 1:$(i) -----" = "----- 1:6 -----"

substr = "🛀?"

subbytes = UInt8[0xf0,0x9f,0x9b,0x80,0xf0,0x9f]

length(subbytes) = 6

"----- 1:$(i) -----" = "----- 1:7 -----"

substr = "🛀?"

subbytes = UInt8[0xf0,0x9f,0x9b,0x80,0xf0,0x9f,0x9b]

length(subbytes) = 7

"----- 1:$(i) -----" = "----- 1:8 -----"

substr = "🛀🛀"

subbytes = UInt8[0xf0,0x9f,0x9b,0x80,0xf0,0x9f,0x9b,0x80]

length(subbytes) = 8



julia> @show endof(s) sizeof(s);

endof(s) = 5

sizeof(s) = 8

I would've thought s[1:5] would give me [0xf0,0x9f,0x9b,0x80,0xf0] and an 
invalid second char, much like s[1:6] and s[1:7].
Also why is endof(s) 5 and not 8?

Reply via email to