First Impressions

Johan Granberg lijat.meREM at OVEgmail.com
Fri Sep 29 09:09:34 PDT 2006


Chad J > wrote:
> Perhaps there should be a string struct/class that has an undefined 
> underlying type (it could be UTF-8, 16, 32, you dunno really), and you 
> could index it to get the *complete* character at any position in the 
> string.  Basically, it is like char[], but it /just works/ in all cases. 
>  I'd almost rather have the size of a char be undefined, and just have 
> char[] be the said magic string type.  If you want something with a 
> ..size of 1, then there is byte/ubyte.  There would probably have to be 
> some stuff in the phobos internals to handle such a string in a correct 
> manner.

I have thought about this to.

> Going even further... if you could make char[] be such a magic string 
> type, then wchar[] and dchar[] could probably be deprecated - use ushort 
> and uint instead.  Then add the following aliases to phobos:
> alias ubyte utf8;
> alias ushort utf16;
> alias uint utf32;

I completely agree, char should hold a character independently of 
encoding and NOT a code unit or something else. I think it would bee 
beneficial to D in the long term if chars where done right (meaning that 
they can store any character) how it is implemented is not important and 
i believe performance is not a problem here, so ease of use and 
correctness would be appreciated.



More information about the Digitalmars-d mailing list