This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
test unicode outfile
Dear Axel Freyn(and any g++ programers/testers):
Thanks your point out.
How about test my first program, which I copied from book(c++
cookbook)(chapter 13 section 1, page 467)
in your system, is that really output anything to file(length > 0)?
--------------
//Example 13-1 Hardcoding a Unicode string
#include <iostream>
#include <fstream>
// #include <wfstream>
#include <string>
using namespace std;
int main() {
// Create some strings with Unicode characters
wstring ws1 = L"Infinity: \u221E";
wstring ws2 = L"Euro: \x20ac";
wchar_t w[] = L"Infinity: \u221E";
// wcout << ws2 << endl << w << endl;
// using std::wofstream;
// std::ios::sync_with_stdio(false);
// std::locale::global(std::locale("en_US.utf8"));
/* wchar_t BOM=0xFEFF;
std::ofstream outFile("unico.dat", std::ios::out | std::ios::binary);
*/
wofstream out("unicode_txt");
/* wofstream m_tempFileListOut;
m_tempFileListOut.open("unico.txt", std::ios:binary);*/
/* static wostream *logstream;
logstream = new wofstream("abc_txt",ios::app); */
//m_tempFileListOut << ws2 << L'\n' << w << L'\n';
// out.write( (char *) ws2.c_str(), ws2.length() * sizeof(wchar_t));
/*
const char *name = "en_US.utf8";
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);
*/
out << ws2 << endl;
/*outFile.write((char *) &BOM, sizeof(wchar_t));
outFile.write((char *) ws2.c_str(), ws2.length() * sizeof(wchar_t));
*/
wcout << ws2 << endl << w << endl;
/*
FILE *pFile;
pFile = fopen("myfile_txt", "bw");
fwrite(w, sizeof(wchar_t), wclen(w), pFile)
fclose(pFile);
*/
}
----------------------------------------------------
if so, would you mind to specify your os(if is linux, which version of
kernel) and gcc/g++ version? Thansk a lot in advance, Eric
On Thu, 2011-06-30 at 10:21 +0200, Axel Freyn wrote:
> Hi Eric,
>
> On Wed, Jun 29, 2011 at 11:37:26PM -0700, eric wrote:
> > On Mon, 2011-06-27 at 19:40 -0400, Jeffrey Walton wrote:
> > > On Mon, Jun 27, 2011 at 7:31 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> > > > On 28 June 2011 00:04, eric wrote:
> > > >>
> > > >>> You need to configure gcc with --enable-clocale=gnu and reinstall it.
> > > >>>
> > > >>> That should be the default on GNU/Linux but apparently your system is
> > > >>> missing something necessary to support named locales.
> > > >>
> > > >> so I do
> > > >> ./configure --enable-clocale=gnu
> > > >
> > > > (You obviously didn't read the installation docs, you're not supposed
> > > > to run ./configure in the source directory)
> > > This seems to come up alot.
> > >
> > > Perhaps ./configure should result in error if cwd is the source
> > > directory. If it does not error, perhaps it should lock up the
> > > keyboard, or shut down the machine to keep folks from moving forward
> > > ;).
> > >
> > > At minimum, it will probably reduce questions on the list.
> > >
> > > Jeff
> >
> > ---------------------------------------------------------------
> > Dear Jeff:
> >
> > you ask us to make a different directory to build rather than source
> > directory but in my system, just at configure, it meet error
> > -----------------------
> > root@eric-laptop:/home/eric/disk# ls
> > Contents-i386 gcc-4.5.2 gcc-build gmp-5.0.2 mpc-0.9 mpfr-3.0.1
> > root@eric-laptop:/home/eric/disk# cd gcc-build
> > root@eric-laptop:/home/eric/disk/gcc-build# ../gcc-4.5.2/configure
> > --enable-clocale=gnu
> > checking build system type... i686-pc-linux-gnu
> > checking host system type... i686-pc-linux-gnu
> > checking target system type... i686-pc-linux-gnu
> > checking for a BSD-compatible install... /usr/bin/install -c
> > checking whether ln works... yes
> > checking whether ln -s works... yes
> > checking for a sed that does not truncate output... /bin/sed
> > checking for gawk... gawk
> > configure: error: building out of tree but ../gcc-4.5.2 contains
> > host-i686-pc-linux-gnu.
> > Use a pristine source tree when building in a separate tree
> > root@eric-laptop:/home/eric/disk/gcc-build#
> > --------------------------------------------------------------
> > plz help
> The problem is, that your source tree is no longer "clean" -- as you did
> already some ./configure or make calls in the source tree.
> The easiest would be to remove the source tree and download a new one
> If not, you can try "make distclean" inside the source-tree (that should
> be sufficient, but I think it's not officially supported)
> > actually I still do that configure in my source directory gcc-4.5.2
> > I do
> > ./configure --enable-clocale=gnu
> > make bootstrap
> > make install-no-fixedincludes
> >
> > still same error of my localetest program
> > --------------------
> > the doc about how to install/build gcc is from the following link
> > ----
> > http://archive.linuxfromscratch.org/lfs-museum/4.1/LFS-BOOK-4.1-HTML/chapter06/gcc.html
> That is the new, up-to-date documentation:
> http://gcc.gnu.org/install/
>
> Axel