The following code seems to cause, depending on system and implementation, either a segfault, sigabrt, or "HLT instruction" exception. import std.stdio; import std.encoding; void main() { writeln(INVALID_SEQUENCE); }
There is a contract in toUTF8 that checks the return value of isValidDchar, but isValidDchar will return true for some code points that toUTF8 does not handle.
It throws an UTF exception nowadays and BTW toUTF8 is not used anymore since it's deprecated in favor of encode().