Boris wrote:
On Sun, 24 Feb 2008 16:46:26 +0200, Ioannis Vranos
<iv*****@nospam .no.spamfreemai l.grwrote:
>[...]Instead of messing with these details, perhaps we should accept
that the C subset setlocale() function defined in <clocaleis simpler
(and thus better)?
The following code works:
#include <iostream>
#include <clocale>
#include <string>
#include <cstdlib>
int main()
{
using namespace std;
if (!setlocale( LC_ALL, "greek" ))
{
cerr<< "NULL returned!\n";
return EXIT_FAILURE;
}
wstring ws;
wcin>ws;
wcout<< ws<< endl;
}
If the locale name "greek" means an eight-bit character set is used you
don't need to use wstring, wcin and wcout at all? What character set do
you actually plan to use in your program?
Boris
I am only experimenting with the wide character support. Is there any
possibility the "greek" locale to be only a 8-bit one? And if it is, how
can it also display english (latin characters)? By using something like
ASCII extended (0-127 latin characters and 128-255 greek characters)?
"locale -a" also displays the following greek encodings:
el_GR
el_GR.iso88597
el_GR.utf8
The following also works:
#include <iostream>
#include <clocale>
#include <string>
#include <cstdlib>
int main()
{
using namespace std;
if (!setlocale( LC_ALL, "el_GR.utf8 " ))
{
cerr<< "NULL returned!\n";
return EXIT_FAILURE;
}
wstring ws;
wcin>ws;
wcout<< ws<< endl;
}
[john@localhost src]$ ./foobar-cpp
Î”Î¿ÎºÎ¹Î¼Î±ÏƒÏ „ικό
Î”Î¿ÎºÎ¹Î¼Î±ÏƒÏ „ικό
[john@localhost src]$
but the following doesn't:
#include <iostream>
#include <locale>
#include <string>
#include <cstdlib>
int main()
{
using namespace std;
wcout.imbue(loc ale("el_GR.utf8 "));
wstring ws;
wcin>ws;
wcout<< ws<< endl;
}
[john@localhost src]$ ./foobar-cpp
Î”Î¿ÎºÎ¹Î¼Î±ÏƒÏ „ικό
[john@localhost src]$