tags:

views:

203

answers:

6

Possible Duplicate:
Unicode in C++

If I remembered correctly, the default character and string encoding in C++ are ASCII. Is there a simple way to enable Unicode support?

+1  A: 

Depends on the version of C++ you are using. C++0x (not entirely released yet but still supported on many compilers) adds native UTF-8 support to the language. Otherwise, no the language does not support UTF-8. C++03 and earlier support unicode through the use of Wide Characters (wchar_t).

Billy ONeal
+2  A: 

Current C++ doesn't specify encoding in any way. You might look into an actual Unicode library like ICU or, on some architectures and implementations you can use wchar_t to manipulate and hold Unicode strings.

Noah Roberts
A: 

Could be helpful to you: Reading UTF-8 in C++ via a pointer

Jen
Why is my link not showing up?
Jen
The HTML was broken. Fixed.
Steve Jessop
Thanks! (It displayed fine in preview)
Jen
+1  A: 

It rather depends what you want to do with the text you are processing. Half the point of UTF-8 is that you don't need to change existing code if it handles 8-bit chars and does nothing special with characters above 128. Of course, strlen is the length in bytes rather than the character or code-point count. So it may be that you have a text in, text out program that can use UTF-8 directly. Or it may be that you're creating a GUI in text and so need to handle ruby and RTL text, in which case your job is much more complicated and you probably need to chose appropriate libraries.

Pete Kirkham
A: 

If u are using Visual Studio then going into the project properties and defining a Preprocessor as _UNICODE does the job for u.

Anuj