Fixed a Unicode problem

This commit is contained in:
Zane U. Ji 2013-12-20 23:14:48 +08:00
parent ca2d7541ed
commit 59a82451a7
1 changed files with 4 additions and 7 deletions

View File

@ -4546,6 +4546,7 @@ bool MyFrame::saveFile ( XmlDoc *doc, wxString& fileName, bool checkLastModified
int bytes = 0; int bytes = 0;
std::string utf8Buffer, encoding, fileNameLocal; std::string utf8Buffer, encoding, fileNameLocal;
wxString wideEncoding;
bool isXml = true; bool isXml = true;
try try
{ {
@ -4553,6 +4554,7 @@ bool MyFrame::saveFile ( XmlDoc *doc, wxString& fileName, bool checkLastModified
XmlEncodingSpy es; XmlEncodingSpy es;
es.parse ( utf8Buffer ); es.parse ( utf8Buffer );
encoding = es.getEncoding(); encoding = es.getEncoding();
wideEncoding = wxString ( encoding.c_str(), wxConvUTF8 );
fileNameLocal = fileName.mb_str ( wxConvLocal ); fileNameLocal = fileName.mb_str ( wxConvLocal );
@ -4615,8 +4617,6 @@ bool MyFrame::saveFile ( XmlDoc *doc, wxString& fileName, bool checkLastModified
} }
else else
{ {
wxString wideEncoding = wxString ( encoding.c_str(), wxConvLocal, encoding.size() );
// IF Unicode, use iconv to convert buffer // IF Unicode, use iconv to convert buffer
if ( encoding == "UTF-16" || encoding == "UTF-16LE" || if ( encoding == "UTF-16" || encoding == "UTF-16LE" ||
encoding == "UTF-16BE" || encoding == "UTF-32" || encoding == "UTF-32LE" || encoding == "UTF-16BE" || encoding == "UTF-32" || encoding == "UTF-32LE" ||
@ -4734,8 +4734,7 @@ bool MyFrame::saveFile ( XmlDoc *doc, wxString& fileName, bool checkLastModified
{ {
auto_ptr<WrapLibxml> wl ( new WrapLibxml ( libxmlNetAccess ) ); auto_ptr<WrapLibxml> wl ( new WrapLibxml ( libxmlNetAccess ) );
int result = wl->saveEncoding ( utf8Buffer, int result = wl->saveEncoding ( utf8Buffer,
doc->getFullFileName(), fileName, NULL, doc->getFullFileName(), fileName, NULL, wideEncoding );
wxString ( encoding.c_str(), wxConvUTF8 ) );
if ( result == -1 ) if ( result == -1 )
{ {
success = saveRawUtf8 ( fileNameLocal, utf8Buffer, false, isXml ); success = saveRawUtf8 ( fileNameLocal, utf8Buffer, false, isXml );
@ -4743,9 +4742,7 @@ bool MyFrame::saveFile ( XmlDoc *doc, wxString& fileName, bool checkLastModified
{ {
wxString wideError = wl->getLastError(); wxString wideError = wl->getLastError();
bytes = utf8Buffer.size(); bytes = utf8Buffer.size();
wxString msg, wideEncoding; wxString msg;
wideEncoding =
wxString ( encoding.c_str(), wxConvUTF8, encoding.size() );
if ( wideError.empty() ) if ( wideError.empty() )
wideError = _ ( "unknown error" ); wideError = _ ( "unknown error" );