Correctly Displaying Characters of Other Languages

So I'm having a problem with displaying the 'ã' character, which is an a with a tilde on it. Originally, I had an issue with displaying characters with any accents correctly, but I've found some code which renders almost all of them properly.

Here's what I've been using (and displays a regular 'a' for 'ã', but everything else correctly):
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <io.h>
#include <fcntl.h>
#include<string>
using namespace std;
int main()
{
	_setmode(_fileno(stdout),_O_U16TEXT);
	// Thanks to: http://cplusplus.com/forum/general/48408/
	string x = "inscrição";
	wcout << x.c_str() << endl;
	system("PAUSE");
}

That outputs this... http://img257.imageshack.us/img257/8983/unledxu.png

I've also looked in the "fcntl.h" header file and seen what other substitutes I could use for _O_U16TEXT, and the others don't present the 'ã' character correctly either.

Is there something else I can do to have these displayed correctly?

Thanks!
http://i.imgur.com/Wz5Dj.png

check out this image i made... it has the int correspondent to every char you can show in console.
as you'd probably see, there is no 'ã'. so in short, you cannot display 'ã' in the c program.
http://i.imgur.com/Wz5Dj.png

check out this image i made... it has the int correspondent to every char you can show in console.
as you'd probably see, there is no 'ã'. so in short, you cannot display 'ã' in the c program.


No, there's no way to display 'ã' with the regular iostream library's available characters. I'm looking for workarounds to display this character correctly, because my target audience is Brazilian. You're basically saying that C++ is incompatible with a 300+ million person country. And since you said "in short", I'd like to know the long explanation (if there is one).

There must be a way to properly display this character, as this webpage even references how to display this character in C++: http://www.fileformat.info/info/unicode/char/00e3/index.htm

If I try entering in cout << "\u00E3";, it gives me some weird character. When I change it to wcout << "\u00E3";, it displays what I showed above.

Is there some better way to handle Unicode characters with C++ then?
Last edited on
apologies if my answer was too short and uninformative. i only have knowledge in C, and i was taught about the 255 characters available in the console. i made use of the knowledge and programmed a program to display the image, as shown, and since the 256th character was the 1st character, and so on, it can be assumed that its a loop. so the console can only display 255 characters, to my knowledge.

its my mistake, i admit it as i didn't know about this. i made some research on this matter and found this link

http://stackoverflow.com/questions/721357/unexpected-output-of-stdwcout-leleve-in-windows-shell

and, quoting some explanation from Dave Van den Eynde
The C++ compiler does not support Unicode in code files. It's not going to produce the desired output in your console, because the console does not support Unicode.

i hope this helps :)

--
edit:
another person here suggested using powershell which allows unicode characters, but i am not sure how to use powershell.

http://stackoverflow.com/questions/379240/is-there-a-windows-command-shell-that-will-display-unicode-characters
Last edited on
Topic archived. No new replies allowed.