toString vs. toUtf8

Sean Kelly sean at f4.ca
Tue Nov 20 15:58:08 PST 2007


Bill Baxter wrote:
> Sean Kelly wrote:
>> As an alternative, I can only suggest that toUTF8, toUTF16, and 
>> toUTF32 be named toString, toWString, and toDString, respectively, and 
>> Unicode should be assumed as the standard encoding format in D.
> 
> 1) On the question of toWString vs toWstring and consistency:
> 
> I don't think there's any clear precedent for either in Tango right now, 
> but my question is, if tango *had* a "to uint" function, what would it 
> be named?  toUInt or toUint?  Whatever the answer to that is should be 
> the same as the answer to how to name a "to wstring" function.

Good question.  Probably toUInt, though I don't like it much :-)  For 
these conversion routines, I'll admit I find the idea that the type name 
should be repeated exactly, which suggests something like to_wstring, 
but I don't imagine anyone finds that appealing.

> 2) On the question of toWString vs toStringW
> 
> It seems to be pretty well agreed in this thread that toWString is more 
> consistent but toStringW is prettier.
> 
> I could be wrong but I think usage pattern of these W and D variants of 
> the functions will be bimodal:  either very frequent or very infrequent. 
>  In the former case I'd probably want to make a simpler alias like 
> 'wstr'.  In the latter case I'd want it to be the most consistent thing 
> possible to be easy to remember for the few times I use it.

Agreed.


Sean



More information about the Digitalmars-d mailing list