Rename std.string.toStringz?

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Jun 20 12:37:01 PDT 2011


We could use std.conv.to to convert strings to char pointers and
vice-versa, however I know of at least two functions which have
different semantics which complicate things:

std.string.toStringz only appends a null and returns the pointer,
std.windows.charset.toMBSz converts the string to the Windows 8-bit
charset and then appends the null and returns the pointer.

So what would to!(char*)(str) do?

The opposite, which currently works:
to!(string)(charPtr);

assumes the char pointer is just a null-terminated string. IIRC there
were bugs in std.registry that were recently fixed where
to!string(char*) was used instead of the fromMBSz function.

So assuming to!() will always do the right thing could be a bad idea.


More information about the Digitalmars-d mailing list