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

Imperatorn johan_forsberg_86 at hotmail.com
Sun Nov 7 16:46:33 UTC 2021


On Sunday, 7 November 2021 at 16:28:33 UTC, kdevel wrote:
> On Sunday, 7 November 2021 at 04:18:25 UTC, Walter Bright wrote:
>> On 11/4/2021 11:30 PM, FeepingCreature wrote:
>>> [...]
>> It's much better than 0.0. 0.0 is indistinguishable from valid 
>> data, and is a very common valid value.
>
> Technically it makes no difference if you do not check for 0.0 
> or not for NaN. What makes a difference is using "out of band 
> signalling" (exceptions) if its default behavior is process 
> termination.
>
>> NaN and ReplacementChar are not valid
>
> The replacemment character '�' is a valid Unicode codepoint 
> (U+FFFD).
>
>> and are easily distinguished.
>
> Someone may forget to write explicit code to handle this case 
> which most likely leads to data corruption. I choose stack 
> trace over potentially corrupted data.

https://docs.microsoft.com/en-us/dotnet/standard/base-types/character-encoding


More information about the Digitalmars-d mailing list