On Friday, 2 April 2021 at 04:49:22 UTC, mw wrote:
On Friday, 2 April 2021 at 04:43:48 UTC, rikki cattermole wrote:
On 02/04/2021 5:38 PM, mw wrote:
On Friday, 2 April 2021 at 04:36:01 UTC, rikki cattermole
wrote:
On 02/04/2021 5:32 PM, mw wrote:
---
import std;
import std.conv : text;
void main()
{
char[6] s;
s = "abc";
writeln(s, s.length); // abc6, ok it's the static
array's length
string t = text("head-", s, "-tail");
writeln(t, t.length); // head-abc-tail16, why?
assert(t[9] == '\0');
}
---
I don't get it, what do you mean by the assertion:
assert(t[9] == '\0');
t == "head-abc-tail"
Not all characters can be printed such as NULL.
[104, 101, 97, 100, 45, 97, 98, 99, 0, 0, 0, 45, 116, 97, 105,
108]
So you mean inside the writeln() call, the 0s are skipped?
Well, if I use `string t` as filename, it will try to looking
for a file called:
"head-abc\0\0\0-tail" instead of just "head-abc-tail" ?
or it's platform dependent?
Then how can I construct `t`? to make this assertion true:
assert(t == "head-abc-tail"); // failed!