On Friday, 27 May 2016 at 13:47:32 UTC, ag0aep6g wrote:
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

I agree. It has happened to me that characters like "é" return length == 2, which has been the cause of some bugs in my code. I'm wiser now, of course, but you wouldn't expect this, if you write

if (input.length == 1)
  speakCharacter(input);  // e.g. when spelling a word
else
  processInput(input);

The worst thing is that you never know, what's going on under the hood and where autodecode slows you down, unbeknownst to yourself.


Reply via email to