I am making Latin-Croatian translator in C++. My problem is that I can't print string with characters like 'š','č','đ' etc, that exist in croatian. So is there a way to input extended ascii characters in string and then output them on screen without using solutions like this one: cout << "String that includes a \x9C sign"; // \x9C is '£'?
Asked
Active
Viewed 3,858 times
-2
-
You might need to use a different codepage. Probably using unicode would serve better than ASCII for your purposes. – πάντα ῥεῖ Feb 08 '14 at 10:11
-
If your system is using utf8: std::cout << "\u00A3\n"; – Feb 08 '14 at 10:19
1 Answers
2
Fisrt of all, you should be clear about source codification, there some discussions around SO about it (like this one).
If you are in an C++11 environment, you can use char16_t
or char32_t
, which are granted to handle chars 16 and 32 bit long, respectively (take a look here). So if you sure all characters can be handled in 16 bits (UTF16), char16_t can be an alternative. AFAIK, wchar_t
is not granted to handle 2 bytes (at least at VS 2005/2008 it is).
To handle UTF-8
, I strong believe that the best alternative if to use codecvt.

Community
- 1
- 1

wesley.mesquita
- 795
- 5
- 12