www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Wide characters support in D

reply Ruslan Nikolaev <nruslan_devel yahoo.com> writes:
 
 I'm well aware why UTF-32 is useful. Earlier, you had
 started out saying 
 that there should only be one string type, the OS-native
 type. Now you're 
 changing your tune and saying that we do need multiple
 types.
 

No. From the very beginning I said "it would also be nice to have some builtin function for conversion to dchar". That means it would be nice to have function that converts from tchar (regardless of its width) to UTF-32. The reason was always clear - you normally don't need UTF-32 chars/strings but for some character analysis you might need them.
Jun 08 2010
next sibling parent Michel Fortin <michel.fortin michelf.com> writes:
On 2010-06-08 04:15:50 -0400, Ruslan Nikolaev <nruslan_devel yahoo.com> said:

 No. From the very beginning I said "it would also be nice to have some 
 builtin function for conversion to dchar". That means it would be nice 
 to have function that converts from tchar (regardless of its width) to 
 UTF-32. The reason was always clear - you normally don't need UTF-32 
 chars/strings but for some character analysis you might need them.

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); } -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Jun 08 2010
prev sibling parent Walter Bright <newshound1 digitalmars.com> writes:
Ruslan Nikolaev wrote:
 No. From the very beginning I said "it would also be nice to have some
 builtin function for conversion to dchar". That means it would be nice to
 have function that converts from tchar (regardless of its width) to UTF-32.
 The reason was always clear - you normally don't need UTF-32 chars/strings
 but for some character analysis you might need them.

http://www.digitalmars.com/d/2.0/phobos/std_utf.html Function overloading takes care of selecting the right version.
Jun 08 2010