This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Do wcout and wcin work with GCC?
- From: "Alex J. Dam" <alexjotadam at yahoo dot com dot br>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 31 Aug 2003 15:27:52 -0300
- Subject: Do wcout and wcin work with GCC?
Hi,
I would like to use C++ as my primary language for computer
programming, but I'm having some problems dealing with
multi-byte strings in g++.
How can I make wcin and wcout work? Whenever I read a string
from the console the string is truncated at the first non-ASCII
character. When I'm writing to wcout, the string is also
truncated.
I've tried imbue(), setlocale(), etc. but it didn't solve my
problem.
My locale is pt_BR.UTF-8, my gcc and g++ are version 3.3.1.
EXAMPLE:
#include <iostream>
#include <string>
#include <locale>
using namespace std;
int main(){
locale l("pt_BR.UTF-8");
setlocale(LC_ALL, "pt_BR.UTF-8");
locale::global(l);
wcout.imbue(l);
wcin.imbue(l);
wstring s;
wcin >> s;
wcout << s.length() << endl;
}
Some output:
$ ./prog
arboris
7
$ ./prog
Ãrvore
0
Any help?
Alex