Post by Antony RiakiotakisHi, I have found traces of a discussion in the MinGW mailing lists about
including w_char support in fstream. Since we do support wide (and,
consequently special unicode) characters in blender and the lack of such
functionality is evident on our MinGW64 builds, I'd like to know the state
of affairs. Has this patch been included in MinGW? Is there a define to
enable it?
What exactly so you mean? I submitted a patch (which was not accepted due
to IMO stupid reasons) to libstdc++ to allow the MS extensions that allow
you to open fstreams with wchar_t/wstring filenames.
wfstream has always supported extracting wchar_t's from a file, but such
functionality is ridiculously nonportable (endianness and more so
sizeof(wchar_t)).
You can work around this by tapping into libstc++'s extension headers. This
is how I fixed it in my code:
#if _WIN32
# if __GLIBCXX__
#include <ext/stdio_filebuf.h>
unique_ptr<istream> open_ifstream(const string& filename)
{
FILE* c_file = _wfopen(convert_to_utf16(filename).c_str(), L"r");
__gnu_cxx::stdio_filebuf<char>* buffer = new
__gnu_cxx::stdio_filebuf<char>(c_file, std::ios_base::in, 1);
return std::unique_ptr<istream>(new istream(buffer));
}
unique_ptr<ostream> open_ofstream(const string& filename)
{
FILE* c_file = _wfopen(convert_to_utf16(filename).c_str(), L"w+");
__gnu_cxx::stdio_filebuf<char>* buffer = new
__gnu_cxx::stdio_filebuf<char>(c_file, std::ios_base::out, 1);
return unique_ptr<ostream>(new ostream(buffer));
}
# elif _MSC_VER
unique_ptr<ifstream> open_ifstream(const string& filename)
{
return unique_ptr<ifstream>(new ifstream(convert_to_utf16(filename)));
}
unique_ptr<ofstream> open_ofstream(const string& filename)
{
return unique_ptr<ofstream>(new ofstream(convert_to_utf16(filename)));
}
# else
// Warning! unknown fstream implementation - no unicode filename support
unique_ptr<ifstream> open_ifstream(const string& filename)
{
return unique_ptr<ifstream>(new ifstream(filename));
}
unique_ptr<ofstream> open_ofstream(const string& filename)
{
return unique_ptr<ofstream>(new ofstream(filename));
}
Obviously you can replace the smart pointers with something else (and
you need to cater for the UTF-16 filename, but you get the idea.
If this is not what you mean, please link to the relevant discussion
or specify more clearly what you're talking about.
Ruben
Post by Antony Riakiotakis------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mingw-w64-public mailing list
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public