digitalmars.D - i18n and string in another locales [charsets],,??
- d-user,again (17/17) May 05 2008 why d compiler refuse to swallow strings [char[] or string] in another...
- Robert Fraser (10/30) May 05 2008 char[] is defined to be UTF-8, which can represent characters in many
- Janice Caron (11/14) May 05 2008 D natively uses Unicode. Unicode can be expressed in three ways,
why d compiler refuse to swallow strings [char[] or string] in another languages?? charset without complain --------------------------------------------------------------------------------------------------- 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'; 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 4]why the compiler depends on the phobos by this intimate relationship d compiler must be generic like c++ ---------------------------------- i know i am BORING but Thanks
May 05 2008
d-user wrote:why d compiler refuse to swallow strings [char[] or string] in another languages?? charset without complainchar[] 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'; 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 statementsYou 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
May 05 2008
2008/5/6 <d-user puremagic.com>:why d compiler refuse to swallow strings [char[] or string] in another languages?? charset without complainD natively uses Unicode. Unicode can be expressed in three ways, called UTF-8 (which uses chars), UTF-16 (which uses wchars), and UTF-32 (which uses dchars). For all other encodings (and incidently, all other encodings are a /subset/ of Unicode), to need to convert to and from Unicode. std.encoding knows also about ASCII, Latin-1, and Windows-1252. std.encoding also provides the EncodingScheme abstract class, from which additional encodings may be subclassed. That module is still in its infancy, but if there is any /specific/ encoding you need support for, let us know.
May 05 2008