Why ElementType!(char[3]) == dchar instead of char?

Justin Whear via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 1 09:25:53 PDT 2015


On Tue, 01 Sep 2015 19:18:42 +0300, drug wrote:

> http://dpaste.dzfl.pl/4535c5c03126

Arrays of char are assumed to be UTF-8 encoded text and a single char is 
not necessarily sufficient to represent a character.  ElementType 
identifies the type that you will receive when (for instance) foreaching 
over the array and D autodecodes the UTF-8 for you.  If you'd like to 
represent raw bytes use byte[3] or ubyte[3].  If you'd like other 
encodings, check out std.encoding.


More information about the Digitalmars-d-learn mailing list