auto-decoding

Seb seb at wilzba.ch
Sun Apr 1 07:20:52 UTC 2018


On Sunday, 1 April 2018 at 02:44:32 UTC, Uknown wrote:
> If you want to stop auto-decoding, you can use 
> std.string.representation like this:
>
> import std.string : representation;
> auto no_decode = some_string.representation;
>
> Now no_decode wont be auto-decoded, and you can use it in place 
> of some_string. You can also use std.utf to decode by graphemes 
> instead.

.representation gives you an const(ubyte)[]

What you typically want is const(char)[], for this you can use 
std.utf.byCodeUnit

https://dlang.org/phobos/std_utf.html#byCodeUnit

There's also this good article:

https://tour.dlang.org/tour/en/gems/unicode


More information about the Digitalmars-d-learn mailing list