April 02

On Friday, 2 April 2021 at 15:01:07 UTC, mw wrote:

>

BTW, shall I log a writeln() improvement bug ?

It's really confusing, e.g as debug print or logs.

In my opinion this isn't a bug. The nulls are actually printed:

$> rdmd test.d | hd
00000000  61 62 63 00 00 00 36 0a  68 65 61 64 2d 61 62 63  |abc...6.head-abc|
00000010  00 00 00 2d 74 61 69 6c  31 36 0a                 |...-tail16.|
0000001b

It's just, that you can't see them, because it's an invisible character.

If you want to get \0 for nulls, you could write

writefln!"%(%s%)"(only(t));

With this, t is printed as a string literal:

"head-abc\0\0\0-tail"
Next ›   Last »
1 2 3