Cross platform C++

Started by
8 comments, last by thedevdan 19 years, 10 months ago
Does it matter whether I use char or wchar_t? Which one should I use (when I deal with individual characters, don''t worry, I am using std::string)?
Not giving is not stealing.
Advertisement
Cross platform doesn''t have anything to do with wide characters, but international does. If you plan on having people from other countries using your app or game, then you should use wide chars.
Yes, that is what I was remembering. Thanks for correcting me.
Not giving is not stealing.
It''s generally a good idea to stick with unicode ("wchar_t") data types in general, as many programming languages always use it, and all the standard functions work with it anyway. character arrays are kind of ugly anyway.

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

I know STL gives you a choice (with strings). I was wondering which one to use, and I think I will use wide chars because ASCII is being phased out.
Not giving is not stealing.
EDIT: Never mind.

OK, I am having trouble using wchar_t. The compiler can't convert things inside of quotes to wstrings.

I get this error: cannot convert from 'const char [61]' to 'const std::wstring'


Is there a pre-quote character I should put to fix this (like #"text")?

EDIT: Yes, L.

[edited by - thedevdan on June 6, 2004 4:56:47 PM]
Not giving is not stealing.
I believe its an L:

L"This is a wide-character string."
quote:Original post by dcosborn
I believe its an L:

L"This is a wide-character string."


Yeah, I just found it while searching the forums. Thanks a lot, though.

Goes to show you should search before asking...
Not giving is not stealing.
you can also use the _T() macro (defined in the tchar header):

#ifdef _UNICODE
#define _T(x) L ## x
#else
#define _T(x) x

_T("Here is a string.")

---------------------------Hello, and Welcome to some arbitrary temporal location in the space-time continuum.

quote:Original post by Etnu
you can also use the _T() macro (defined in the tchar header):

#ifdef _UNICODE
#define _T(x) L ## x
#else
#define _T(x) x

_T("Here is a string.")



Thanks for the tip, but I don''t think I will need it because I will be explicitly using wchar_ts.

Not giving is not stealing.

This topic is closed to new replies.

Advertisement