char array weirdness

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 28 16:14:31 PDT 2016


On 29.03.2016 00:49, Jack Stouffer wrote:
> But the value fits into a char; a dchar is a waste of space. Why on
> Earth would a different type be given for the front value than the type
> of the elements themselves?

UTF-8 strings are decoded by the range primitives. That is, `front` 
returns one Unicode code point (type dchar) that's pieced together from 
up to four UTF-8 code units (type char). A code point does not fit into 
the 8 bits of a char.


More information about the Digitalmars-d-learn mailing list