On Friday 08 October 2004 18:53, Prabu Subroto wrote:
QString lines, line; QFile file; file.flush(); QDir::setCurrent( "/localhome/patrixlinux/arsip/proyek/qt/kvclient" ); file.setName( "otentik.txt" ); file.open(IO_ReadWrite); int i = 0; QTextStream str(&file); line = file.readLine(lines, 50); lines = QString::fromLatin1(line);
^^^^^^^^^^^^^^^^
This is a bad idea.
You silently assume that every text you read is encoded in Latin1 - which may
or may not be appropriate. You should rather use the current locale settings.
On a SuSE Linux system, UTF-8 is the default locale - but of course the user
can override that. So you should rather check the LANG and LC_CTYPE
environment variables and use the appropriate encoding conversion - like
QString::fromLocal8Bit() or QString::fromUtf8().
Maybe even QTextCodec::codecForLocale() can figure that out more easily -
altough I have to admit I never used that one.
For more details, see
http://doc.trolltech.com/3.3/qstring.html#fromLocal8Bit
http://doc.trolltech.com/3.3/qstring.html#fromUtf8
http://doc.trolltech.com/3.3/qtextcodec.html#codecForLocale
CU
--
Stefan Hundhammer