Newbie question about special characters in QLabel
I'm trying to display a "registered trademark" symbol (u+00AE) in the text of a QLabel. Yes, I've read the other posts on the forum on this topic but I'm failing to implement them.
I read the string from a database, store it in a QString, then use that to set the QLabel.setText(). The symbol appears as an open rectangle. I've used style sheets to set various font families on the QLabel and they all appear as various sized rectangles.
So I tried turning the string from the database (theQSqlQuery->value(2).toByteArray()) into a QString by using the QString::fromUtf8() function. This makes the symbol appear as a question mark. QString::fromLocal8bit() does the same thing.
Does anybody have suggestions as to what I am doing wrong?
Thanks!
Re: Newbie question about special characters in QLabel
What is the encoding of your database?
Re: Newbie question about special characters in QLabel
Well, I hate to waste your time, but I'm not really sure of the encoding of my database.
I'm working in a Windows XP environment. My content provider writes up the description fields of the database in Microsoft Word (in which he includes trade mark symbols, non-breaking spaces, and other characters with an ASCII value higher than 128), and cuts & pastes them into a Microsoft Excel spreadsheet. The spreadsheet is exported as a *.csv file. My Python script transforms this into an *.sql file and runs it through Sqlite3 to make the database file. The Qt app reads it in with a QSqlDatabase::addDatabase("QSQLITE", dbName[i]) statement.
If you can have pity on a clueless newbie and tell me how to determine the encoding of my database I would be happy to do it for you.
Re: Newbie question about special characters in QLabel
Then most probably your encoding is broken. You have to make sure sqlite3 stores the data in UTF-8. Unfortunately the console (sqlite3) doesn't do that - it uses local encoding (latin1 most probably in your case). You have to somehow fix that. For example by filling the database using Qt.
Re: Newbie question about special characters in QLabel