Fix utf8 handling in libkcal/icalformat

This resolves bug 2660

Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
pull/21/head
Emanoil Kotsev 8 years ago committed by Slávek Banko
parent 105df0826e
commit 63c4d2db47

@ -88,14 +88,14 @@ bool ICalFormat::load( Calendar *calendar, const TQString &fileName)
return false; return false;
} }
TQTextStream ts( &file ); TQTextStream ts( &file );
ts.setEncoding( TQTextStream::Latin1 ); ts.setEncoding( TQTextStream::UnicodeUTF8 );
TQString text = ts.read(); TQString text = ts.read();
file.close(); file.close();
if ( text.stripWhiteSpace().isEmpty() ) // empty files are valid if ( text.stripWhiteSpace().isEmpty() ) // empty files are valid
return true; return true;
else else
return fromRawString( calendar, text.latin1() ); return fromRawString( calendar, text.utf8() );
} }
@ -123,7 +123,8 @@ bool ICalFormat::save( Calendar *calendar, const TQString &fileName )
// Convert to UTF8 and save // Convert to UTF8 and save
TQCString textUtf8 = text.utf8(); TQCString textUtf8 = text.utf8();
file.file()->writeBlock( textUtf8.data(), textUtf8.size() - 1 ); file.textStream()->setEncoding( TQTextStream::UnicodeUTF8 );
file.file()->writeBlock(textUtf8.data(),textUtf8.size()-1);
if ( !file.close() ) { if ( !file.close() ) {
kdDebug(5800) << "KSaveFile: close: status was " << file.status() << ". See errno.h." << endl; kdDebug(5800) << "KSaveFile: close: status was " << file.status() << ". See errno.h." << endl;

Loading…
Cancel
Save