Hi all,
how can I print correctly accented letters in my MessageBox?
If I write "cafè" it appears with the tilde.
You should not store accented characters in sources.
It is prone to all kind of problems (as you have discovered).
Try porting things to another OS, or move them around thru
some not-so-smart source control solutions, and you will get
more troubles.
You must always know the encoding of the file.
And you should always inform the compiler about that
(but unfortunately not all compilers can do something with that info)
In this case it looks like you are saving the source file as UTF-8
(but it is hard to tell, because the encoding of your copy-paste
depends on the news client, has nothing to do with your sources)
Giving hex values would help more.
Anyway, to store accented characters in the sources you must
- have the sources in the OS system encoding
or
- have the sources saved as UTF-16
or
- use Unicode strings and escape the high-ascii values
(for instance L"caf\u00e8")
Each option has its own problems.
For the first, move the file to another OS, or even try to compile
on a foreign system, and you are in trouble. Same if you want
(let's say) Japanese strings and to compile on a US system.
For the second, very few compilers, source control systems, diff
applications, can deal with UTF-16. Quite sad for 2010, but true.
The right thing is to store the strings in sources, and move them
to resources. That's why they were invented.