[Issue 19518] std.range.front() returns a dchar when applied to char[]

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 27 06:10:19 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19518

Basile B. <b2.temp at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp at gmx.com

--- Comment #1 from Basile B. <b2.temp at gmx.com> ---
This is not a bug. D standard library auto decoded input ranged of char and
wchar so their ElementEncodingType is dchar. The reasoning behind is this is
that imagine an array such as

   ['é','µ','ç'] (which is somewhat equivalent to the string "éµç".dup btw)

You'd expect 3 elements, not 6. So if you want to get rid of decoding, cast
your array as ubyte[] (or use std.range.byCodeUnit)

--


More information about the Digitalmars-d-bugs mailing list