Rename std.string.toStringz?

Steven Schveighoffer schveiguy at yahoo.com
Mon Jun 20 12:20:49 PDT 2011


On Mon, 20 Jun 2011 15:15:36 -0400, Jonathan M Davis <jmdavisProg at gmx.com>  
wrote:

> On 2011-06-20 10:43, Steven Schveighoffer wrote:
>> On Mon, 20 Jun 2011 09:23:22 -0400, Andrei Alexandrescu
>>
>> <SeeWebsiteForEmail at erdani.org> wrote:
>> > Technically you're right. Yet I think it's pretty widespread that a  
>> sole
>> > char* means a zero-terminated string.
>>
>> I think it's pretty widespread that you shouldn't be using  
>> zero-terminated
>> strings ;)
>>
>> But I suppose it makes sense that to can convert from a char[] to a char
>> *, and if it does, it doesn't hurt to do the safest thing.  I think it
>> should be discouraged, however, in favor of doing toUTFz which is more
>> descriptive as a function name.
>
> So, you're arguing that we should introduce toUTFz for converting  
> character
> arrays to zero-terminated strings, and then have std.conv.to use it when
> converting from character arrays to character pointers?

Exactly.  The reason for to calling it is because that is the safest  
option (albeit not completely safe).

-Steve


More information about the Digitalmars-d mailing list