Re: [Php-qt-users] QLineEdit and utf-8 strings - unicode support
Status: Beta
Brought to you by:
tm243
From: Thomas M. <tm...@ip...> - 2006-01-17 00:15:07
|
=46erenc Veres wrote on Dienstag, 17. Januar 2006 00:29: > 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 ( const char * str ) <- looks to be this one now Exactly. And=20 QString ( QChar ch ) works too. But remember that a char is a number,"a" is a string instead. So= =20 you have to use use $mystring =3D new QString(65); Normally it is possible to provide all constructors, but the others are sti= ll=20 broken in the current version. Next time I will fire up an improved kalyptu= s=20 script again to solve it. > 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. it should print "h=C3=A1llo" to console. > Even the non-latin 1 "=C5=91" character works right! And both "toUtf8" and > simple "echo" prints the characters right. (I use a Konsole configured > for UTF-8.) (I tested with strings from the database too, same result.) =46ine. > So it looks like the string is just travelling in binary format. (?) The string is stored in the QString object. The zend engine passes it from= =20 your code to the object. In your tests you have proven that it works. > 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.) The fromUtf8 function does not work for me, I got segfaults. What is with this piece of code: $text =3D new QString($my_database_fetched_variable); $myLineEdit->setText($text); Note, what we are doing is experimental and the php guys are working on the= =20 same problems with other tools. I read some of Andrei's implementations in= =20 php6 and they implemented a function which copies unicode strings to normal= =20 php strings. For php_qt this should be done by Qt's QString::toAscii(), I=20 passed the resulting bytearray to a string directly. =2D-=20 Thomas |