On Tuesday, 21 April 2015 at 13:06:22 UTC, JohnnyK wrote:
On Monday, 20 April 2015 at 19:24:01 UTC, Panke wrote:
On Monday, 20 April 2015 at 18:03:50 UTC, John Colvin wrote:
On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote:
To measure the columns needed to print a string, you'll need
the number of graphemes. (d|)?string.length gives you the
number of code units.
Even that's not really true.
Why? Doesn't string.length give you the byte count?
I was talking about the "you'll need the number of graphemes".
s.length returns the number of elements in the slice, which in
the case of D's string types gives is the same as the number of
code units.
I think what you are looking for is string.sizeof?
From the D reference
.sizeof Returns the array length multiplied by the number of
bytes per array element.
.length Returns the number of elements in the array. This is a
fixed quantity for static arrays. It is of type size_t.
That is for static arrays only. .sizeof for slices is just
size_t.sizeof + T*.sizeof i.e. 8 on 32 bit, 16 on 64 bit.