Re: [Php-qt-users] QLineEdit and utf-8 strings - unicode support
Status: Beta
Brought to you by:
tm243
From: Ferenc V. <li...@ne...> - 2006-01-16 23:29:22
|
Hi! >> Does not work: >> $this->txtGuessPercents[$i]->$text =3D $tr["percent"]."%"; >> >> Error message: "Cannot access empty property". According to the Qt Well, actually that should be ->text, which dumps core, instead that error message. :-) > This is not possible. PHP-properties are provided as you can see in Ok, I did not even remember that C++ can do actions when setting a property! (Been too long time ago.) PHP could do that only via __set(), but maybe that would be too much overload. (Both to php_qt developers and CPU. :-) ) Reasonable. The only problem I could see, is that sometimes setting the property and using the access method has different effects on various checks and signals in Qt4. I don't know if that will cause problems, of course PHP programmers must take extra care of these changes, that's all. I am not sure about that, just browsing QLineEdit docs and thinking... > I improved the QString class and toUtf8() works fine. But I get too muc= h=20 > segfaults with other functions so I have to spend more time to it. > You can put any QString class object to php's echo or print methods, pl= ease=20 > consider test/qstring.php and test/unicode.php. Thanks you! :-) First a little note: $txt =3D new QString(""); $txt->toUtf8(); segfaults. While seeing your examples, I cannot see how it will work with non-English strings. E.g. since PHP can implement only one of the 8 constructors, which one will it be? Or will use use "is_a()" to implement more? Sounds very difficult. QString () QString ( const QChar * unicode, int size ) QString ( QChar ch ) QString ( int size, QChar ch ) QString ( const QLatin1String & str ) QString ( const QString & other ) QString ( const char * str ) <- looks to be this one now QString ( const QByteArray & ba ) Seeing from the "test/unicode.php": $QString =3D new QString("hello"); I really don't know. If I upload the object with "h=C3=A1llo" instead, it still prints the string back, I use KWrite in "UTF-8" mode for the test. Even the non-latin 1 "=C5=91" character works right! And both "toUtf8" an= d simple "echo" prints the characters right. (I use a Konsole configured for UTF-8.) (I tested with strings from the database too, same result.) So it looks like the string is just travelling in binary format. (?) There is no such thing as "plain text"! :-) Do you remember my old screenshot with broken utf-8 text: http://www.wpsnet.hu/~lion/gui.png ? I think that could be fixed only with QString, something like: $text =3D QString::fromUtf8($my_database_fetched_variable); // static m. $myLineEdit->setText($text); // (Passing QString there drops core.) Ok, I stop testing CHARS for now, and leave you with your original schedule, just please, take a note on charset support. ;-) Thanks, Ferenc |