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

drug via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 1 09:40:24 PDT 2015


On 01.09.2015 19:32, Justin Whear wrote:
> On Tue, 01 Sep 2015 16:25:53 +0000, Justin Whear wrote:
>
>> 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.
>
> I should correct this:
>   * ForeachType is the element type that will inferred by a foreach loop
>   * ElementType is usually the same as ForeachType but is the type of the
> value returned by .front
>
> One major distinction is that ElementType is only for ranges while
> ForeachType will work for iterable non-ranges.
>
I'm just trying to automatically convert D types to hdf5 types so I 
guess char[..] isn't obligatory some form of UTF-8 encoded text. Or I 
should treat it so?


More information about the Digitalmars-d-learn mailing list