might be a bug in the DMD FrontEnd
Deewiant
deewiant.doesnotlike.spam at gmail.com
Fri Mar 30 03:16:00 PDT 2007
Daniel Keep wrote:
> That said, I personally think that if you need to use printf because
> writefln is barfing on your string, then that's a bug in your program.
> char[] is UTF-8: if you're not storing UTF-8, you should be using
> ubyte[], not char[].
I agree. However, both Phobos and Tango use char[] for all their
string-processing functions _which also work on non-UTF-8_. This means that to
call such a function you need to do, for instance,
"std.string.strip(*cast(char[])iso-8859-1-string.ptr);" which gets ugly very
quickly.
I hoped that Tango would use ubyte[] in the C standard library, at least, but
no. I understand why not (standard; most people use only char[] and don't want
to do the cast from char[]* to ubyte[]* as above; good for ASCII anyway), and so
I don't complain, but it's still something I'd like.
Perhaps D needs a way to allow implicit conversion:
finally(ubyte[] is char[]) {
char[] foo(ubyte[] myString) {
return std.string.strip(myString.dup);
}
}
<g>
More information about the Digitalmars-d
mailing list