From: "Alex J. Dam" <alexjotadam@yahoo.com.br>
To: gcc-help@gcc.gnu.org
Subject: Do wcout and wcin work with GCC?
Date: Sun, 31 Aug 2003 18:28:00 -0000 [thread overview]
Message-ID: <oprur78q2fp1r0ql@mail.yahoo.com.br> (raw)
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
next reply other threads:[~2003-08-31 18:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-31 18:28 Alex J. Dam [this message]
2003-09-02 17:43 lrtaylor
2003-09-02 19:55 ` Alex J. Dam
2003-09-05 2:10 ` Alex J. Dam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=oprur78q2fp1r0ql@mail.yahoo.com.br \
--to=alexjotadam@yahoo.com.br \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).