Bug 14370 – std.utf.toUTF8 has an incorrect contract
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-03-29T02:09:22Z
Last change time
2020-03-21T03:56:32Z
Assigned to
No Owner
Creator
erikas.aubade
Comments
Comment #0 by erikas.aubade — 2015-03-29T02:09:22Z
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);
}
Comment #1 by briancschott — 2015-03-29T02:11:43Z
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.
Comment #2 by b2.temp — 2017-09-14T16:48:11Z
It throws an UTF exception nowadays and BTW toUTF8 is not used anymore since it's deprecated in favor of encode().