public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jaworski at autograf dot pl" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/37298]  New: no output when use wcout and cout, wrong utf16 -> utf8 conversion
Date: Sun, 31 Aug 2008 16:20:00 -0000	[thread overview]
Message-ID: <bug-37298-16650@http.gcc.gnu.org/bugzilla/> (raw)

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

Hi!
I wrote my first std::wstring program and have found bug in libstdc++!

*  the exact version of GCC
gcc version 4.2.3 (4.2.3-6mnb1)

* the system type;
Linux Mandriva 2008.1 PowerPack

* the options given when GCC was configured/built;
./configure --prefix=/usr --libexecdir=/usr/lib --with-slibdir=/lib
--mandir=/usr/share/man --infodir=/usr/share/info --enable-checking=release
--enable-languages=c,c++,ada,fortran,objc,obj-c++,java
--host=i586-manbo-linux-gnu --with-cpu=generic --with-system-zlib
--enable-threads=posix --enable-shared --enable-long-long --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --enable-java-awt=gtk
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --enable-gtk-cairo
--disable-libjava-multilib --enable-ssp --disable-libssp

* the complete command line that triggers the bug;
g++ couttest.cpp -o couttest; ./couttest

* the compiler output (error messages, warnings, etc.)
There is no error or warrning messages.

Important think:
$ locale
LANG=pl_PL.UTF-8
...

I wrote this program (couttest.cpp):
#include <string>
#include <iostream>
#include <locale>
int main()
{
   std::wstring wstr(L"letters1:&#261;&#347;&#322;ó&#322;&#380;&#378;");
   std::string str("letters2:&#261;&#347;&#322;ó&#322;&#380;&#378;");

   std::wcout.imbue(std::locale(""));
   std::cout.imbue(std::locale(""));

   std::wcout << wstr << std::endl;
   std::cout << str << std::endl;
}
Output is:
letters1:???????

Second line doesn't appear.
Another problem: why I can't see polish letters??? I expect that conversion
from UTF-16 to UTF-8 is quite trivial. Besides I think, that conversion is
often case.

But let change above program:
#include <string>
#include <iostream>
#include <locale>
int main()
{
   std::wstring wstr(L"letters1:&#261;&#347;&#322;ó&#322;&#380;&#378;");
   std::string str("letters2:&#261;&#347;&#322;ó&#322;&#380;&#378;");

   std::wcout.imbue(std::locale(""));
   std::cout.imbue(std::locale(""));

   std::cout << str << std::endl;
   std::wcout << wstr << std::endl;
}
Output is:
letters2:&#261;&#347;&#322;ó&#322;&#380;&#378;
letters1:[B&#65533;B|z

Both lines appear. But in this case wcout output is different than in first
program - why??? Correct cout output is not suprise, as sources are in utf-8 -
in this case there is no conversion.


I think that there are two bugs: 1) lack of whole line in first program's
output 2) wrong output (wrong conversion from utf-16 to utf-8).

Jacek Jaworski


-- 
           Summary: no output when use wcout and cout, wrong utf16 -> utf8
                    conversion
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jaworski at autograf dot pl


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


             reply	other threads:[~2008-08-31 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-31 16:20 jaworski at autograf dot pl [this message]
2008-08-31 18:16 ` [Bug libstdc++/37298] " paolo dot carlini at oracle dot com
2008-08-31 18:25 ` paolo dot carlini at oracle dot com
2008-08-31 20:15 ` jaworski at autograf dot pl
2008-08-31 20:58 ` paolo dot carlini at oracle dot com

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=bug-37298-16650@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).