On Wednesday, 20 September 2017 at 15:04:08 UTC, jmh530 wrote:
testing_utf16.d(5): Error: Truncated UTF-8 sequence
testing_utf16.d(6): while evaluating: static assert((_error_) == (wstring
))
Failed: ["dmd", "-unittest", "-v", "-o-", "testing_utf16.d", "-I."]

https://dlang.org/spec/lex.html#hex_strings says:

The string literals are assembled as UTF-8 char arrays, and the postfix is applied to convert to wchar or dchar as necessary as a final step.

This isn't the friendliest thing ever and is contrary to my expectations too. You basically have to encode your string into UTF-8 and then paste the hex of that in.

What should work is escape sequences:

    wstring str = "\u03c0"w;

Reply via email to