D - Conversion of char* to wchar*
- Russ Lewis (6/6) Aug 18 2001 What happens in this cast:
- Walter (6/12) Aug 18 2001 It undergoes a simple pointer conversion, and is pretty obviously a codi...
- weingart cs.ualberta.ca (Tobias Weingartner) (4/9) Aug 20 2001 That begs the question, "What character set is the language written
- Russell Bornschlegel (10/12) Aug 20 2001 If you mean "what character set does the language expect source to
What happens in this cast: char *myString = "asdf"; wchar *myUnicodeString = (wchar*)myString; If we do a simple pointer conversion, then we have lost the string meaning of the pointer, which, while technically correct is most likely not what 95% of the code writers would have wanted.
Aug 18 2001
Russ Lewis wrote in message <3B7F3BCB.6C07277D deming-os.org>...What happens in this cast: char *myString = "asdf"; wchar *myUnicodeString = (wchar*)myString; If we do a simple pointer conversion, then we have lost the string meaning of the pointer, which, while technically correct is most likely not what 95% of the code writers would have wanted.It undergoes a simple pointer conversion, and is pretty obviously a coding bug. Doing a cast on a string literal *will* convert the string itself, as: char *astring = "asdf"; // an ASCII version of "asdf" wchar *wstring = "asdf"; // makes a unicode version of "asdf" No need to put the L prefix on the string.
Aug 18 2001
In article <9lnimq$1ht9$1 digitaldaemon.com>, Walter wrote:Doing a cast on a string literal *will* convert the string itself, as: char *astring = "asdf"; // an ASCII version of "asdf" wchar *wstring = "asdf"; // makes a unicode version of "asdf"That begs the question, "What character set is the language written in?" Will that be configurable? Will it be ascii? Etc, etc... --Toby.
Aug 20 2001
Tobias Weingartner wrote:That begs the question, "What character set is the language written in?" Will that be configurable? Will it be ascii? Etc, etc...If you mean "what character set does the language expect source to appear in," that's addressed in http://www.digitalmars.com/d/lex.html : Unicode
Aug 20 2001