toString vs. toUtf8

Kris foo at bar.com
Mon Nov 19 21:22:16 PST 2007


"Daniel Keep" <daniel.keep.lists at gmail.com> wrote in >
> 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.


Tango already has this ....

>
> -- Daniel 





More information about the Digitalmars-d mailing list