The Case Against Autodecode

ag0aep6g via Digitalmars-d digitalmars-d at puremagic.com
Fri May 27 06:47:32 PDT 2016


On 05/27/2016 03:32 PM, Andrei Alexandrescu wrote:
>>> However the following do require autodecoding:
>>>
>>> s.walkLength
>>> s.count!(c => !"!()-;:,.?".canFind(c)) // non-punctuation
>>> s.count!(c => c >= 32) // non-control characters
>>>
>>> Currently the standard library operates at code point level even
>>> though inside it may choose to use code units when admissible. Leaving
>>> such a decision to the library seems like a wise thing to do.
>>
>> But how is the user supposed to know without being a core contributor to
>> Phobos?
>
> Misunderstanding. All examples work properly today because of
> autodecoding. -- Andrei

They only work "properly" if you define "properly" as "in terms of code 
points". But working in terms of code points is usually wrong. If you 
want to count "characters", you need to work with graphemes.

https://dpaste.dzfl.pl/817dec505fd2


More information about the Digitalmars-d mailing list