need someone who know how to install localization data file in ubuntu
eric
fsshl at att.net
Tue Jun 28 01:27:09 UTC 2011
Dear Ubuntu10.04 programers:
I have trouble on output unicode character/string to file.
the following is the running result(failed since bad configure
locale/name on my system-10.04 upgrade to 2.6.35-25)
code
gcc-help mailing list's programer's suggestion/diagno
which conclude I need I need someone who know how to install
localization data file in ubuntu.
--------------------------------------------------------
root at eric-laptop:/home/eric/cppcookbook# ./a.out
trying to access locale en_US.utf8
Couldn't generate locale en_US.utf8: locale::facet::_S_create_c_locale
name not valid
Error when writing to file
root at eric-laptop:/home/eric/cppcookbook# ./a.out POSIX
trying to access locale POSIX
Generated locale C
Error when writing to file
root at eric-laptop:/home/eric/cppcookbook# ./a.out C
trying to access locale C
Generated locale C
Error when writing to file
root at eric-laptop:/home/eric/cppcookbook# ./a.out en_US.utf8
trying to access locale en_US.utf8
Couldn't generate locale en_US.utf8: locale::facet::_S_create_c_locale
name not valid
Error when writing to file
root at eric-laptop:/home/eric/cppcookbook#
----------------------------------------------------------------
#include <iostream>
#include <fstream>
#include <string>
//#include <cstring>
using namespace std;
int main(int argc, char *argv[]) {
wstring ws2 = L"Euro: \x20ac";
wofstream out("unicode.txt");
if(not out.good())
cerr << "Error opening output file" << endl;
//const char *name = "el_GR.utf8";
const char *name = "en_US.utf8";
if(argc == 2)
name = argv[1];
cout << "trying to access locale " << name << endl;
locale loc;
try{
loc = locale(name);
cout << "Generated locale " << loc.name() << endl;
}catch( exception &e){
cerr << "Couldn't generate locale " << name << ": " << e.what() <<
endl;
}
out.imbue(loc);
if(not out.good())
cerr << "Error when setting the locale" << endl;
out << ws2<< endl;
if(not out.good())
cerr << "Error when writing to file" << endl;
}
-------------------------------------------------------------------
gnu/gcc/gcc camp's programers told me this is not the issue of gcc, but
Ubuntu,
he ask me to looking for /etc/locale
this is his email reply/dialog/debug
--------------------------------------------------------
So the problem must be with your glibc setup.
>>
>> Is en_US.utf8 listed in /etc/locale.gen? Any other locales?
>> Uncomment the ones you want to support, then try running
>> /usr/sbin/locale-gen as root
>> (I don't know if that's the right way to generate locale data for
>> Ubuntu, you might want to ask on an Ubuntu forum)
>>
>> I've just tried it on a Debian box which only has en_US.utf8 locale
>> data installed, and Axel's test program worked ok and running
"./a.out
>> en_US.utf8" wrote to the file unicode.txt, so the problem is not with
>> the code or gcc.
> ----------------------------
> my system don't have /etc/locale.gen
> but
> it have /etc/locale.alias
That isn't the same.
You'll need to find someone who knows how to install localization data
files on Ubuntu.
This isn't a gcc issue.
-------------------------------------------------------------------------------------------------------------------------------------------
so plz help, and thanks a lot in advance, Eric, fsshl at att.net
More information about the ubuntu-users
mailing list