zipios: unicode handling in ZipOutputStream

This commit is contained in:
wmayer
2022-08-31 17:05:31 +02:00
parent 818a8add04
commit 88ce83b68c

View File

@@ -5,6 +5,9 @@
#include "zipoutputstreambuf.h"
#include "zipoutputstream.h"
#if defined(_WIN32) && defined(ZIPIOS_UTF8)
#include <Base/FileInfo.h>
#endif
using std::ostream;
@@ -25,7 +28,12 @@ ZipOutputStream::ZipOutputStream( const std::string &filename )
: std::ostream( nullptr ),
ofs( nullptr )
{
#if defined(_WIN32) && defined(ZIPIOS_UTF8)
std::wstring wsfilename = Base::FileInfo(filename).toStdWString();
ofs = new std::ofstream( wsfilename.c_str(), std::ios::out | std::ios::binary ) ;
#else
ofs = new std::ofstream( filename.c_str(), std::ios::out | std::ios::binary ) ;
#endif
ozf = new ZipOutputStreambuf( ofs->rdbuf() ) ;
this->init( ozf ) ;
}