This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
unicode outfile testprogram, plz post your os/g++ version
> >> >> 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
> >
> > And I do this step, after I copy that link's sample locale.gen on my
> > /etc/ directory.
> >
> >> >> (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.
> > ------------------------------------------------------------
> > I follow the link and its suggestion(hardway)
> > --
> > http://people.debian.org/~schultmc/locales.html
> >
> > --------------
> >
> > A sample /etc/locale.gen
> > # This file lists locales that you wish to have built. You can find a list
> > # of valid supported locales at /usr/share/i18n/SUPPORTED. Other
> > # combinations are possible, but may not be well tested. If you change
> > # this file, you need to rerun locale-gen.
> > #
> > # XXX GENERATED XXX
> > #
> > # NOTE!!! If you change this file by hand, and want to continue
> > # maintaining manually, remove the above line. Otherwise, use the command
> > # "dpkg-reconfigure locales" to manipulate this file. You can manually
> > # change this file without affecting the use of debconf, however, since it
> > # does read in your changes.
> >
> > en_US.UTF-8 UTF-8
> > ----------------------------------------------------------------
> > then run again test code
>
> Did you run locale-gen?
>
>
> > Not work
> > same error, by out << sw2 << endl;
> > out.good() is 0
> > and when I use no argument, just ./a.out, error
> > can not generate locale
> >
> > looking to see any experienced c/g++ and ubuntu/linux programer's help
> > thanks a lot in advance
> > Eric
> >
> >
> >
Would you please post your test os(linux kernel version) and which g++
version you use, especially when you pass the test
-------------
#include <iostream>
#include <fstream>
#include <string>
//#include <cstring>
using namespace std;
int main(int argc, char *argv[]) {
/* try {
std::locale::global(std::locale(""));
} catch ( ... ) { }; */
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;
}
------------
thanks your cooperation a lot in advance, Eric