Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

thedevdan

Cross platform C++

This topic is 5224 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.")

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!