i18n and string in another locales [charsets],,??

Robert Fraser fraserofthenight at gmail.com
Mon May 5 17:22:46 PDT 2008


d-user wrote:
> why  d compiler refuse to swallow  strings [char[] or string] in another languages??
> c/c++  java/c# etc... comiplers/interpreters can  swallow strings  in any charset
> without complain

char[] is defined to be UTF-8, which can represent characters in many 
languages. DMD (and maybe GDC) requires that the source file be in one 
of ASCII, UTF-8, UTF-16, or UTF-32, so there shouldn't be a problem. If 
you want to accept strings of other charsets in your code (i.e. from a 
network or file), use ubyte[] and/or convert it to UTF-{8, 16, 32}.

> ---------------------------------------------------------------------------------------------------
> and i want to know  why i can't do these things too:
> 
> 1]Suppose we have  a String Class  with Constructors String(char)/String(char[])/String(String) So why I can't do this
> String  mystr="Hello,World";  // Or
> String  mystr='c';
> 
> there is no implicit constructor conversion in d  like  c++/java/c#
> 2] construct like this  char[4] str=new char[4] {'A','B','C','D'};
> 3] I know  that  java importing with *   [import  xx.yy.*;] is slow  but with * importing  it is not necessary to write  every time  about 5 to 10 lines of import 
> statements

You already got answers to these three in your other post. Please don't 
double-post. If the answers were confusing, follow-up there.

> 4]why  the compiler depends on the phobos by this intimate relationship
>    d compiler must be generic like c++

C/C++ has a runtime component, too. D's is a bit bigger because of 
things like the garbage collector, etc.

> ----------------------------------
> i know i am BORING but
> 
> Thanks




More information about the Digitalmars-d mailing list