size of a string in bytes
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jan 28 10:57:39 PST 2017
On Saturday, 28 January 2017 at 18:04:58 UTC, Nestor wrote:
> I believe I saw somewhere that in D a char was not neccesarrily
> the same as an ubyte because chars sometimes take more than
Not true in the language, but the Phobos library does treat char
and ubyte differently because of the multi-char things.
But the built-in .length on a string and indexing all work the
same as bytes.
Note that .length on a wstring or dstring (utf-16 or utf-32) are
not bytes, but words. So wstring.length = number of wchars =
number of 16 bit items. And dstring is 32 bit. Exactly the same
as ushort[].length or int[].length - it is length of elements so
if you actually want byte length, you'd cast it first or
something.
More information about the Digitalmars-d-learn
mailing list