-2

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 '£'?

user3137147
  • 243
  • 1
  • 4
  • 8

1 Answers1

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