[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: russian texts
From: Waldo Bastian <bastian () kde ! org>
Date: 2003-06-30 14:36:15
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday 30 June 2003 15:37, Joerg Anders wrote:
> Important are only the implementations of the 2 slots which
> shall write/read the text in "ifeld_" as UFT8
> (or should I use Unicode ???) to some file:
>
> #define TEXTFILE "/tmp/xxx.txt"
I hope that's only for testing, if not you better use KTempFile.
> void UTFText::writeInternationalText() {
> ofstream out;
> out.open(TEXTFILE);
> if (!out) { /* error */ }
> out << ifeld_->text().utf8() << endl;
> out.close();
> }
>
> void UTFText::readInternationalText() {
> char buffer[1000];
> QString s;
> ifstream in;
> in.open (TEXTFILE);
>
> if (!in) { /* error */ }
> in.getline(buffer, 1000);
> s = QString::fromUtf8(buffer);
> ifeld_->setText(s);
> }
I recommend:
void UTFText::writeInternationalText() {
QFile file(TEXTFILE);
if (!file.open(IO_WriteOnly))
return; // Error
QTextStream stream(&file);
stream.setEncoding( QTextStream::UnicodeUTF8 );
stream << ifeld_->text();
file.close();
if (file.status() != IO_Ok )
return; // Error
}
void UTFText::readInternationalText() {
QFile file(TEXTFILE);
if (!file.open(IO_ReadOnly))
return; // Error
QTextStream stream(&file);
stream.setEncoding( QTextStream::UnicodeUTF8 );
QString s;
stream >> s;
file.close();
ifeld_->setText(s);
}
Cheers,
Waldo
- --
bastian@kde.org -=|[ SuSE, The Linux Desktop Experts ]|=- bastian@suse.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE/AErfN4pvrENfboIRAiWxAJ4xcyAhOIvulEyZTKrMEItJOJdN9gCgpTYj
/2TX0UJRVYz6ohrOPkV79P0=
=mmKF
-----END PGP SIGNATURE-----
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic