The Case Against Autodecode

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Tue May 31 12:48:36 PDT 2016


On 31.05.2016 21:40, Wyatt wrote:
> On Tuesday, 31 May 2016 at 19:20:19 UTC, Timon Gehr wrote:
>>
>> The 'length' of a character is not one in all contexts.
>> The following text takes six columns in my terminal:
>>
>> 日本語
>> 123456
>
> That's a property of your font and font rendering engine, not Unicode.

Sure. Hence "context". If you are e.g. trying to manually underline some 
text in console output, for example in a compiler error message, 
counting the number of characters will not actually be what you want, 
even though it works reliably for ASCII text.

> (Also, it's probably not quite six columns; most fonts I've tested, 漢字
> are rendered as something like 1.5 characters wide, assuming your
> terminal doesn't overlap them.)
>
> -Wyatt

It's precisely six columns in my terminal (also in emacs and in gedit).

My point was, how can std.algorithm ever guess correctly what you 
/actually/ intended to do?


More information about the Digitalmars-d mailing list