On Thursday, August 23, 2012 02:07:52 bearophile wrote:
> Jonathan M Davis:
> > But given that you can use ubyte[] just fine
> 
> The data I am processing is not generic octets, like 8 bits
> digitized by some old A/D converter, they are chars, and I expect
> to see strings when I print them :-)
> 
> > and the fact that using ASCII really shouldn't be encouraged,
> 
> For generic text I agree with you, using UTF-8 is safer and
> better.
> But there is plenty of scientific/technical text-encoded data
> that is in ASCII, and for both practical and performance reasons
> in D I want to process it as a sequence of chars (or a sequence
> of ubytes, as you say). So for some kinds of data that
> encouragement is a waste of your time.

Then just use ubyte[], and if you need char[] for printing out, then cast it. 
And if you don't like the casting, you can ever wrap it in a function.

char[] fromASCII(ubyte[] str)
{
 return cast(char[])str;
}

Creating an ASCII range type will just encourage its use, when you should only 
be operating on ASCII when you really need it. Operating on ASCII is quite 
possible as it is and isn't even very hard. So, I really don't see much benefit 
in adding such a range, and the fact that arguably would encourage bad 
behavior then makes it _undesirable_ rather than just not particularly 
beneficial.

- Jonathan M Davis

Reply via email to