dmd foreach loops throw exceptions on invalid UTF sequences, use replacementDchar instead

deadalnix deadalnix at gmail.com
Fri Nov 5 14:10:35 UTC 2021


On Friday, 5 November 2021 at 13:26:00 UTC, Andrei Alexandrescu 
wrote:
> "On demand" is not "auto".

 From the bug repport:

> A simple foreach loop:
> 
>     void test(char[] a)
>     {
>         foreach (char c; a) { }
>     }
> 
> will throw a UtfException if `a` is not a valid UTF string. 
> Instead, it should replace the invalid sequence with 
> replacementDchar.

This shouldn't do anything related to unicode at all.


More information about the Digitalmars-d mailing list