The Case Against Autodecode

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 2 14:43:51 PDT 2016


On 02.06.2016 23:23, Andrei Alexandrescu wrote:
> On 6/2/16 5:19 PM, Timon Gehr wrote:
>> On 02.06.2016 23:16, Timon Gehr wrote:
>>> On 02.06.2016 23:06, Andrei Alexandrescu wrote:
>>>> As the examples show, the examples would be entirely meaningless at
>>>> code
>>>> unit level.
>>>
>>> So far, I needed to count the number of characters 'ö' inside some
>>> string exactly zero times,
>>
>> (Obviously this isn't even what the example would do. I predict I will
>> never need to count the number of code points 'ö' by calling some
>> function from std.algorithm directly.)
>
> You may look for a specific dchar, and it'll work. How about
> findAmong("...") with a bunch of ASCII and Unicode punctuation symbols?
> -- Andrei
>
>

.̂ ̪.̂

(Copy-paste it somewhere else, I think it might not be rendered 
correctly on the forum.)

The point is that if I do:

".̂ ̪.̂".normalize!NFC.byGrapheme.findAmong([Grapheme("."),Grapheme(",")])

no match is returned.

If I use your method with dchars, I will get spurious matches. I.e. the 
suggested method to look for punctuation symbols is incorrect:

writeln(".̂ ̪.̂".findAmong(",.")); // ".̂ ̪.̂"


(Also, do you have an use case for this?)


More information about the Digitalmars-d mailing list