Rename std.string.toStringz?

Dmitry Olshansky dmitry.olsh at gmail.com
Thu Jun 16 10:59:24 PDT 2011


On 16.06.2011 20:07, KennyTM~ wrote:
> On Jun 16, 11 23:09, Regan Heath wrote:
>> On Thu, 16 Jun 2011 13:00:23 +0100, Timon Gehr <timon.gehr at gmx.ch> 
>> wrote:
>>
>>> Daniel Gibson wrote:
>>>> Am 16.06.2011 08:30, schrieb Jonathan M Davis:
>>>>
>>>>>
>>>>> 3. Rename it to toCString (probably renaming toUTF16z to something 
>>>>> like
>>>>> toWCString), so it's then more recognizable to newbies
>>>>
>>>> This + keep around aliases for the old names until D3.
>>
>> +1
>>
>>> +1. But make it 'toCWString'. :o)
>>
>> Or toWString (looks nicer to me).
>>
>
> A potential problem is that an immutable(wchar)[] is wstring.
>
>> Or toCStr and toWStr (to save 3 characters on each).
>>
>> winnt.h defines many similar types:
>>
>> typedef __nullterminated WCHAR *NWPSTR, *LPWSTR, *PWSTR;
>> typedef __nullterminated PWSTR *PZPWSTR;
>> typedef __nullterminated CONST PWSTR *PCZPWSTR;
>> typedef __nullterminated WCHAR UNALIGNED *LPUWSTR, *PUWSTR;
>> typedef __nullterminated CONST WCHAR *LPCWSTR, *PCWSTR;
>> typedef __nullterminated PCWSTR *PZPCWSTR;
>> typedef __nullterminated CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR;
>>
>> so variations on any of those make sense.
>>
>> .. I think the toStringz probably came from the winnt.h defines using 
>> z..
>>
>> typedef __nullterminated CHAR *NPSTR, *LPSTR, *PSTR;
>> typedef __nullterminated PSTR *PZPSTR;
>> typedef __nullterminated CONST PSTR *PCZPSTR;
>> typedef __nullterminated CONST CHAR *LPCSTR, *PCSTR;
>> typedef __nullterminated PCSTR *PZPCSTR;
>>
>
> Stringz means "Z"ero-terminated "String". The usage predates Windows NT.

I suspect it's original name was Z-string and indeed it's usage started 
much earlier (e.g. it was used in PC BIOS).
To be more precise there was notation for ACSII string that comes form 
having two types of strings:
L-string  - Length is in first byte (so up 255 characters)
Z-string - Zero byte at the end. (or ASCIIZ)

Anyway I could live with any of  toStringz, toZString, toStringZ, toCString.

-- 
Dmitry Olshansky



More information about the Digitalmars-d mailing list