On 10/22/2015 11:10 AM, Nordlöw wrote:
How do I convert a `string` containing Unicode escape sequences such as
"\uXXXX" into UTF-8?

It's already UTF-8 because it's a 'string'. :)

import std.stdio;

void main() {
    auto s = "\u1234";

    foreach (codeUnit; s) {
        writefln("%02x %08b", codeUnit, codeUnit);
    }
}

The output has three code units for "U+1234 ETHIOPIC SYLLABLE SEE", not two bytes:

e1 11100001
88 10001000
b4 10110100

Ali

Reply via email to