[phobos] UTF-8 string slicing

Walter Bright walter at digitalmars.com
Fri Aug 19 19:49:33 PDT 2011



unDEFER wrote:
>
> The fact which the next code
> ----
> writeln( arr.length );
> arr.popFront();
> writeln( arr.length );
> ----
> prints 9 after 10 for any array but for UTF-8 and UTF-16 strings may 
> print as well 8 or lesser, seems too confusing for me.
>

There isn't any getting away from understanding that UTF-8 is a 
multi-byte encoding. If you want to use an encoding with a 1:1 
correspondence between indices and characters, use dchar encoding.


More information about the phobos mailing list