toString vs. toUtf8

Daniel Keep daniel.keep.lists at gmail.com
Mon Nov 19 19:56:58 PST 2007


That's roughly what I've suggested before, except that I also suggested
the following interface:

interface UtfConversion
{
    char[] toUtf8();
    wchar[] toUtf16();
    dchar[] toUtf32();
}

This would allow all objects to have a distinct set of methods for
lossless conversion to different encodings, whilst still preserving the
"just give me something to throw at the user" toString method.

Incidentally, given that to(T)'s entire purpose is to do generalised
*value-preserving* conversions, is this really a problem?  Using a
formatter will always give you something, whilst to!(charT[])(v) will
always preserve the value of the conversion.

	-- Daniel



More information about the Digitalmars-d mailing list