When dmd prints a string literal in an error message it doesn't handle non-trivial cases properly:
```
"before \0 after";
"\n";
```
Error: declaration expected, not `"before "`
Error: declaration expected, not `"\x0a"`
It truncates at zero bytes and uses \x00 codes for everything non-printable, even when there are more readable escape sequences available (most commonly \n for \x0A).
non-ASCII code units in wstrings and dstrings also get messed up in semantic errors:
```
pragma(msg, "\u1234"w.stringof); // "\x34\x12"w
pragma(msg, "\u1234"d.stringof); // "\x34\x12"d
```
The lexer handles these correctly by emitting \u sequences instead of \x sequences.
Comment #1 by dlang-bot — 2022-02-15T20:27:45Z
@dkorpel created dlang/dmd pull request #13662 "Fix issue 22776 - string literal printing fails on non-ASCII/non-printable chars" fixing this issue:
- Fix issue 22776 - string literal printing fails on non-ASCII/non-printable chars
https://github.com/dlang/dmd/pull/13662
Comment #2 by dlang-bot — 2022-02-16T03:51:42Z
dlang/dmd pull request #13662 "Fix issue 22776 - string literal printing fails on non-ASCII/non-printable chars" was merged into master:
- d4471395045078a943cfba00edc5efa0ed2aab52 by dkorpel:
Fix issue 22776 - string literal printing fails on non-ASCII/non-printable chars
https://github.com/dlang/dmd/pull/13662