Today's programming challenge - How's your Range-Fu ?

rumbu via Digitalmars-d digitalmars-d at puremagic.com
Mon Apr 20 13:48:59 PDT 2015


On Monday, 20 April 2015 at 19:24:01 UTC, Panke wrote:
> On Monday, 20 April 2015 at 18:03:50 UTC, John Colvin wrote:
>> On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote:
>>> To measure the columns needed to print a string, you'll need 
>>> the number of graphemes. (d|)?string.length gives you the 
>>> number of code units.
>>
>> Even that's not really true.
>
> Why? Doesn't string.length give you the byte count?

You'll also need the unicode character display width:
Even if the font is monospaced, there are characters (Katakana, 
Hangul and even in Latin script) with variable width.


ABCDEFGH
ABCDEFGH (unicode 0xff21 through 0xff27).

If the text above is not correctly displayed on your computer, a 
Korean console can be viewed here:

http://upload.wikimedia.org/wikipedia/commons/1/14/KoreanDOSPrompt.png





More information about the Digitalmars-d mailing list