Wide characters support in D

Ruslan Nikolaev nruslan_devel at yahoo.com
Tue Jun 8 06:22:02 PDT 2010


> 
> Is this what you want?
> 
>     version (utf16)
>         alias wchar tchar;
>     else
>         alias char tchar;
> 
>     alias immutable(tchar)[] tstring;
> 
>     import std.utf;
> 
>     unittest {
>         tstring tstr =
> "hello";
>         dstring dstr =
> toUTF32(tstr);
>     }
> 

Yes, I think something like this but standardized by the language. Also would be nice to have for interoperability (like I also mentioned in the beginning) toUTF16, toUTF8, fromUTF16, fromUTF8, fromUTF32, as tchar can be anything. If it's UTF-16, and you do toUTF16 - it won't do actual conversion, rather use input string instead. Something like this.

The other point of argument - whether to use this kind of type as the main character type. My point was that having this kind of type used in dynamic libraries would be nice since you don't need to provide instances for every other character type, and at the same time - use native character encoding available on system. Of course it does not mean, that you should be deprived of other types. If you need specific type to do something specific, you can always use it.


      


More information about the Digitalmars-d mailing list