lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] MinGW, wstring, and wstream [Was: patch: compilation fix for w


From: Vadim Zeitlin
Subject: Re: [lmi] MinGW, wstring, and wstream [Was: patch: compilation fix for wx 2.9]
Date: Sat, 15 May 2010 15:13:29 +0200

On Sat, 15 May 2010 12:59:12 +0000 Greg Chicares <address@hidden> wrote:

GC> On 2010-05-15 12:30Z, Vadim Zeitlin wrote:
GC> > On Sat, 15 May 2010 14:23:37 +0200 Vaclav Slavik <address@hidden> wrote:
GC> > 
GC> > VS> >  - MinGW gcc, IIRC, doesn't support wide strings, at least not for
GC> > VS> >    gcc-3.x (which is what we still use for production). 
GC> > VS> 
GC> > VS> I'm not aware of such limitations. Looking at Poedit VCS history, its
GC> > VS> version 1.3.5 required Unicode build of wx and was compiled with MinGW
GC> > VS> 3.4.
GC> > 
GC> >  MinGW 3.x console IO doesn't support Unicode AFAIK. But this is not the
GC> > main problem, it's the lack of support for Unicode file names in
GC> > std::fstream (and lack of extensions in GNU C++ library to remedy this)
GC> > that is. IOW we can support Unicode file names with MinGW, of course. But
GC> > only using wx and not std::fstream.
GC> 
GC> MinGW provides wstring, but not wstream:

 Sorry, this is irrelevant. We don't need wstream because we don't need to
work with Unicode file contents. We just want to be able to open files with
Unicode names and this isn't helped by using wstream as its ctor (and the
underlying std::basic_filebuf::open() method) still take "const char *"
only and not "const wchar_t *" (which is a MSVC extension).

GC> We could use <boost/filesystem/fstream.hpp>, but I doubt that would help:
GC> 
GC>   http://www.cygwin.com/ml/cygwin/2009-01/msg00436.html

 Again, this problem is real and bad enough but is irrelevant to this
discussion.

GC> I'd strongly prefer to write as much code as we can in the subset of
GC> standard C++ that's supported by the compiler we use for production
GC> releases, keeping lmi's core independent of wx. Within that limitation,
GC> there's not much we can do to permit wide characters here:
GC> 
GC>   bool CensusDocument::DoSaveDocument(wxString const& filename)
GC>   {
GC> +     std::ofstream ofs(filename.mb_str(), ios_out_trunc_binary());
GC> -     std::ofstream ofs(filename.c_str(), ios_out_trunc_binary());
GC>       doc_.write(ofs);
GC> 
GC> unless we fall back on <cstdio>, which is just too balky.

 Yes, using <cstdio> would work because MinGW does support _wfopen() (when
using MSVC runtime). So would using wx[F]File or wx[F]FileOutputStream.

 Regards,
VZ

reply via email to

[Prev in Thread] Current Thread [Next in Thread]