Hi,

One can get the length of a string easily, however since strings are UTF-8, sometimes characters take more than one byte. I would like to know then how many bytes does a string take, but this code didn't work as I expected:

import std.stdio;
void main() {
  string mystring1;
string mystring2 = "A string of just 48 characters for testing size.";
  writeln(mystring1.sizeof);
  writeln( mystring2.sizeof);
}

In both cases the size is 8, so apparently sizeof is giving me just the default size of a string type and not the size of the variable in memory, which is what I want.

Ideas?

Reply via email to