public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/15733] New: getline(wifstream, wstring) seems to be broken with UTF-8
@ 2004-05-31 14:04 ahlgren at lysator dot liu dot se
  2004-05-31 14:11 ` [Bug libstdc++/15733] " ahlgren at lysator dot liu dot se
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: ahlgren at lysator dot liu dot se @ 2004-05-31 14:04 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]

To following code doesn't work with non-ascii characters in UTF-8: 
 
#include <iostream> 
#include <string> 
#include <locale> 
#include <clocale> 
#include <fstream> 
 
using namespace std; 
 
int main() 
{ 
  setlocale(LC_ALL, ""); 
  locale loc(""); 
  wcin.imbue(loc); 
  wcout.imbue(loc); 
 
  wifstream fin("test.txt"); // contains the UTF-8 string "ett smörgåsbord\n" 
 
  wstring s; 
  while (fin >> s) { 
    wcout << s << L" "; 
  } 
 
} 
 
This will print: "ett sm ". 
Now substitute "while (fin >> s)" for "while (wcin >> s)" and do: 
"echo 'ett smörgåsbord' | ./test", this will work as expected, printing: 
"ett smörgåsbord ". The problems seems to be in wifstream (the same problem is 
present in wfstream).

-- 
           Summary: getline(wifstream, wstring) seems to be broken with UTF-
                    8
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ahlgren at lysator dot liu dot se
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15733


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2004-05-30 14:35 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-31 14:04 [Bug libstdc++/15733] New: getline(wifstream, wstring) seems to be broken with UTF-8 ahlgren at lysator dot liu dot se
2004-05-31 14:11 ` [Bug libstdc++/15733] " ahlgren at lysator dot liu dot se
2004-05-31 14:16 ` pinskia at gcc dot gnu dot org
2004-05-31 14:33 ` ahlgren at lysator dot liu dot se
2004-05-31 14:44 ` ahlgren at lysator dot liu dot se
2004-05-31 14:56 ` pcarlini at suse dot de
2004-05-31 14:59 ` ahlgren at lysator dot liu dot se
2004-05-31 15:04 ` pinskia at gcc dot gnu dot org
2004-05-31 15:12 ` ahlgren at lysator dot liu dot se
2004-05-31 15:29 ` ahlgren at lysator dot liu dot se
2004-05-31 15:34 ` pcarlini at suse dot de
2004-05-31 15:36 ` ahlgren at lysator dot liu dot se
2004-05-31 16:20 ` pcarlini at suse dot de
2004-05-31 16:22 ` ahlgren at lysator dot liu dot se

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).