[Bug libstdc++/37673] Programs fail to execute with a runtime error when locale is set
ivranos at freemail dot gr
gcc-bugzilla@gcc.gnu.org
Tue Sep 30 09:53:00 GMT 2008
------- Comment #8 from ivranos at freemail dot gr 2008-09-30 09:51 -------
Note: Change the encoding of your browser and email client to Greek-ISO or
Unicode, so as to see the messages correctly.
locale -a displays the following:
john@john-desktop:~/Desktop/download/extract$ locale -a
C
el_CY.utf8
el_GR.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZW.utf8
POSIX
john@john-desktop:~/Desktop/download/extract$
==> Using these locales in the 3 of the 4 codes supplied, they work OK.
However the code number (3.) works only for "en_US.utf8", and it doesn't work
for "el_GR.utf8".
For "en_US.utf8":
#include <iostream>
#include <locale>
#include <string>
int main()
{
using namespace std;
wcin.imbue(locale("en_US.utf8"));
wcout.imbue(locale("en_US.utf8"));
wstring ws;
wcin>> ws;
wcout<< ws<< endl;
}
john@john-desktop:~/Desktop/download/extract$ ./main
Test
Test
john@john-desktop:~/Desktop/download/extract$
For: "el_GR.utf8"
#include <iostream>
#include <locale>
#include <string>
int main()
{
using namespace std;
wcin.imbue(locale("el_GR.utf8"));
wcout.imbue(locale("el_GR.utf8"));
wstring ws;
wcin>> ws;
wcout<< ws<< endl;
}
john@john-desktop:~/Desktop/download/extract$ ./main
Δοκιμαστικό
john@john-desktop:~/Desktop/download/extract$
As I said, the locales work in the 3 of the 4 codes supplied, but code number
(3.) doesn't.
So this isn't a "blocker" bug, but there is still a bug with wcin.imbue() and
wcout.imbue() when they are used alone without a
"locale::global(locale("en_US"));"
or
"ios_base::sync_with_stdio(false);"
statement.
wofstream works OK without any of the above statements.
For example the code:
#include <locale>
#include <string>
#include <fstream>
int main()
{
using namespace std;
wstring ws=
L"Δοκιμαστικό\n";
wofstream file("filename.txt");
file.imbue(locale("el_GR.utf8"));
if(file.is_open())
file<< ws;
}
works OK:
john@john-desktop:~/Desktop/download/extract$ g++ -ansi -pedantic-errors -Wall
main.cpp -o main
john@john-desktop:~/Desktop/download/extract$ cat filename.txt
Δοκιμαστικό
john@john-desktop:~/Desktop/download/extract$
--
ivranos at freemail dot gr changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|blocker |normal
Status|RESOLVED |UNCONFIRMED
GCC host triplet| |Ubuntu 8.04 x86
Resolution|DUPLICATE |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37673
More information about the Gcc-bugs
mailing list