proposal string std.utf:sanitizeUTF(string) which returns an always valid UTF8 string
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Mon Dec 19 04:40:56 PST 2016
On Sunday, December 18, 2016 18:29:16 Timothee Cour via Digitalmars-d wrote:
> I keep running into issues due to auto-decoding (arguably a significant
> design flaw of phobos) when using strings from external sources (which may
> not be 100% valid UTF8) eg see stracktrace [1] on
> getSomeExternalString().splitLines,
>
> Could we have something like `sanitizeUTF` in std.utf, to allow for a
> simple fix when running into such UTF8 issues see proposal implementation
> [2]; the fix would then be:
> ```
> getSomeExternalString().splitLines,
> =>
> getSomeExternalString().sanitizeUTF.splitLines,
> ```
Use std.utf.byUTF:
http://dlang.org/phobos/std_utf.html#byUTF
- Jonathan M Davis
More information about the Digitalmars-d
mailing list