Wide characters support in D

justin justin at economicmodeling.com
Mon Jun 7 15:50:43 PDT 2010


This doesn't answer all your questions and suggestions, but here goes.
In answer to #1, "Hello world" is a literal of type char[] (or string). If you want
to use UTF-16 or 32, use "Hello world"w and "Hello world"d respectively.
In partial answer to #2 and #3, it's generally pretty easy to adapt a string
function to support string, wstring, and dstring by using templating and the fact
that D can do automatic conversions for you. For instance:

string blah = "hello world";
foreach (dchar c; blah)   // guaranteed to get a full character
  // do something


More information about the Digitalmars-d mailing list