PDA

View Full Version : QTextStream under Mac OS X



hunsrus
14th September 2009, 09:49
Hi folks!

im having several problems again - concerning the mac and file encoding. its about Csv - exporting a file. when trying to do that with iostream under windows, everything works fine for me, but using the same code under os x, two chars for one unicode character (basically umlauts) are produced.
thus, i tried the QFile and QTextStream classes to write the file for me. Without success as well.
i hoped this


QFile outfile;
outfile.setFileName(fileName);
outfile.open(QFile::WriteOnly);
QTextCodec::setCodecForCStrings(QTextCodec::codecF orLocale());
QString strtowrite = "aeßiouöüäß";
QTextStream stream( &outfile );
//stream.setCodec(QTextCodec::codecForLocale());
stream << strtowrite;
outfile.close();
would solve the problem, but obviously the umlauts are ignored completely. only ascii text is put into the file.
and then i tried something like directly telling the qtextstream, which encoding to use using setCodec() and so on. but that didnt work as well!!
http://lists.trolltech.com/qt-interest/2008-04/thread00143-0.html provides a solution with Q3TextStream, but the header could not be found on my system.

when i try to read a csv file edited in the mac-text editor, it reads just garbage. please help me...

regards
sebbo