public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/35353]  New: C++ wide character locale doesn't work
@ 2008-02-24 14:07 ivranos at freemail dot gr
  2008-02-24 14:12 ` [Bug c++/35353] " ivranos at freemail dot gr
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: ivranos at freemail dot gr @ 2008-02-24 14:07 UTC (permalink / raw)
  To: gcc-bugs

The following code works:

#include <iostream>
#include <clocale>
#include <string>

int main()
{
    using namespace std;

    char *p= setlocale( LC_ALL, "greek" );

    if (!p)
      cerr<< "NULL returned!\n";

    wstring ws;

    wcin>> ws;

    wcout<< ws<< endl;
} 

[john@localhost src]$ ./foobar-cpp 
&#916;&#959;&#954;&#953;&#956;&#945;&#963;&#964;&#953;&#954;&#972;
&#916;&#959;&#954;&#953;&#956;&#945;&#963;&#964;&#953;&#954;&#972;
[john@localhost src]$ 



The following code DOES NOT work:

#include <iostream>
#include <locale>
#include <string>

int main()
{
    using namespace std;

    wcout.imbue(locale("greek")); 

    wstring ws;

    wcin>> ws;

    wcout<< ws<< endl;
} 


[john@localhost src]$ ./foobar-cpp 
&#916;&#959;&#954;&#953;&#956;&#945;&#963;&#964;&#953;&#954;&#972;

[john@localhost src]$ 


For the code that does not work:

[john@localhost src]$ g++ -v -save-temps -ansi -pedantic-errors -Wall main.cc
-o foobar-cpp 
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic
--host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)
 /usr/libexec/gcc/i386-redhat-linux/4.1.2/cc1plus -E -quiet -v -D_GNU_SOURCE
main.cc -mtune=generic -ansi -pedantic-errors -Wall -fpch-preprocess -o main.ii
ignoring nonexistent directory
"/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2

/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/i386-redhat-linux
 /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/backward
 /usr/local/include
 /usr/lib/gcc/i386-redhat-linux/4.1.2/include
 /usr/include
End of search list.
 /usr/libexec/gcc/i386-redhat-linux/4.1.2/cc1plus -fpreprocessed main.ii -quiet
-dumpbase main.cc -mtune=generic -ansi -auxbase main -pedantic-errors -Wall
-ansi -version -o main.s
GNU C++ version 4.1.2 20070626 (Red Hat 4.1.2-14) (i386-redhat-linux)
        compiled by GNU C version 4.1.2 20070626 (Red Hat 4.1.2-14).
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129413
Compiler executable checksum: a9d7d7ea3146608fff5ae7eec9c8ae61
 as -V -Qy -o main.o main.s
GNU assembler version 2.17.50.0.6-5.el5 (i386-redhat-linux) using BFD version
2.17.50.0.6-5.el5 20061020
 /usr/libexec/gcc/i386-redhat-linux/4.1.2/collect2 --eh-frame-hdr -m elf_i386
--hash-style=gnu -dynamic-linker /lib/ld-linux.so.2 -o foobar-cpp
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o
/usr/lib/gcc/i386-redhat-linux/4.1.2/crtbegin.o
-L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2
-L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.. main.o -lstdc++ -lm -lgcc_s
-lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/i386-redhat-linux/4.1.2/crtend.o
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtn.o
[john@localhost src]$


-- 
           Summary: C++ wide character locale doesn't work
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ivranos at freemail dot gr


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


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

end of thread, other threads:[~2010-04-08  9:44 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-24 14:07 [Bug c++/35353] New: C++ wide character locale doesn't work ivranos at freemail dot gr
2008-02-24 14:12 ` [Bug c++/35353] " ivranos at freemail dot gr
2008-02-24 14:16 ` ivranos at freemail dot gr
2008-02-24 14:18 ` pcarlini at suse dot de
2008-02-24 14:24 ` ivranos at freemail dot gr
2008-02-24 14:35 ` ivranos at freemail dot gr
2008-02-24 14:41 ` pcarlini at suse dot de
2008-02-25 12:04 ` [Bug libstdc++/35353] " ivranos at freemail dot gr
2008-02-25 12:13 ` ivranos at freemail dot gr
2008-02-25 12:45 ` pcarlini at suse dot de
2008-02-25 12:45 ` pcarlini at suse dot de
2008-02-25 13:11 ` pcarlini at suse dot de
2008-02-25 14:19 ` pcarlini at suse dot de
2008-08-31 18:16 ` paolo dot carlini at oracle dot com
2008-09-30 10:23 ` paolo dot carlini at oracle dot com
2009-09-14 21:10 ` paolo dot carlini at oracle dot com
2010-02-21  1:32 ` paolo dot carlini at oracle dot com
2010-04-08  2:33 ` luca dot barbieri at gmail dot com
2010-04-08  9:44 ` paolo dot carlini at oracle dot com

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