Bug 21815 – std.format: invalid UTF-character throws with width but not without

Status
NEW
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-04-09T15:35:28Z
Last change time
2024-12-01T16:38:41Z
Assigned to
No Owner
Creator
Berni44
Moved to GitHub: phobos#10461 →

Comments

Comment #0 by bugzilla — 2021-04-09T15:35:28Z
char[1] c; writefln!"%s"(c[]); writefln!"%5s"(c[]); The first writefln prints 0xff-character, while the second one throws an UFTException: "Attempted to decode past the end of a string (at index 1)". IMHO, the second one should not throw, but just write some (four?) spaces and a 0xff-character.
Comment #1 by bugzilla — 2021-05-04T09:23:57Z
Reading the unicode standard, I think, I erred here on what should happen. Actually, the invalid 0xff character should be replaced by a 0xFFFD-replacement character in both versions (or both versions should throw, but that is not recommended any more, because it might permit a denial of service attack).
Comment #2 by robert.schadek — 2024-12-01T16:38:41Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10461 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB