Re: wcout, wprintf() only print English
On Feb 23, 2:59 pm, Jeff Schwab <j...@schwabcenter.com> wrote:
Ioannis Vranos wrote:
Jeff Schwab wrote:
Perhaps when you copy and paste the greek text, you copy
garbage (that is, not viewing the message in the correct
character set in your newsgroup reader).
So, I repost the code in this message which is encoded to
Unicode (UTF-8):
#include <iostream>
int main()
{
using namespace std;
wcout<< L"=CE=94=CE=BF=CE=BA=CE=B9=CE=BC=CE=B1=CF=83=CF=84=CE=B9=
=CE=BA=CF=8C =CE=BC=CE=AE=CE=BD=CF=85=CE=BC=CE=B1\n";
}
Thanks, you were correct.
Here's what I thought was "supposed" to be the portable solution:
#include <iostream>
#include <locale>
int main() {
std::wcout.imbue(std::locale("el_GR.UTF-8"));
std::wcout << L"=CE=94=CE=BF=CE=BA=CE=B9=CE=BC=CE=B1=CF=83=CF=84=CE=
=B9=CE=BA=CF=8C =CE=BC=CE=AE=CE=BD=CF=85=CE=BC=CE=B1\n";
}
However, my system still shows question marks for this. For
whatever it's worth, here's the (probably incorrect) way that
appears to work on my system:
#include <iostream>
#include <locale>
int main() {
std::cout.imbue(std::locale(""));
std::cout << "=CE=94=CE=BF=CE=BA=CE=B9=CE=BC=CE=B1=CF=83=CF=84=CE=B9=
=CE=BA=CF=8C =CE=BC=CE=AE=CE=BD=CF=85=CE=BC=CE=B1\n";
}
You're still not telling us a lot of important information.
What is the actual encoding used in the source file, and what
are the bytes actually output. (FWIW: I think g++, and most
other compilers, just pass the bytes through transparently in a
narrow character string. Which means that your second code will
output whatever your editor put in the source file. If you're
using the same encoding everywhere, it will seem to work.)
Note that there isn't really any portable solution, because so
much depends on things the C++ compiler has no control over.
Run the same code in two different xterm, and it can output two
different things, completely; just specify a different font
(option -fn) with a different encoding for one of the xterm.
(And of course, it's pretty much par for the course to see one
thing when you cat to the screen, and something else when you
output the same file to the printer.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=C3=A9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=C3=A9mard, 78210 St.-Cyr-l'=C3=89cole, France, +33 (0)1 30 23 00 3=
4