[Issue 14519] [Enh] foreach on strings should return replacementDchar rather than throwing
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat May 2 03:40:08 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14519
--- Comment #25 from Vladimir Panteleev <thecybershadow at gmail.com> ---
(In reply to Martin Nowak from comment #24)
> If we validate encoding on data entry points such as readText or byLine,
> then decoding errors should be assertions rather than silent replacements,
> because it's a programming error to use unvalidated data as string.
Although I think this approach is acceptable (as long as the program halts
regardless of compilation flags, which shouldn't be a problem), I would like to
note that there are situations in which it is impractical to either convert or
validate the data. One example is implementations of text-based network
protocols (e.g. HTTP, NNTP, SMTP). Here, neither converting everything to UTF-8
or verifying that it is valid UTF-8 works, because text-based protocols often
embed raw binary data. The program only needs to parse the ASCII text parts, so
the ideal solution would be a string handling library which never decodes UTF-8
(something D doesn't have).
--
More information about the Digitalmars-d-bugs
mailing list