Qt-interest Archive, December 2006
MySQL Encoding
Message 1 in thread
Hello everyone,
I have a MySQL database that uses Windows-1251 encoding. When I try to
read values from the database into Qt QString or a QTableView, I get
either question marks, or unreadable characters (if I init connection
with SET NAMES 'cp1251')
What is the right way to use MySQL database if the data contained in the
DB is not English. Is there are any way not to use UTF8 for the
database? Just set a default encoding to the connection?
Best regards,
Oleg Romanenko
--
[ signature omitted ]
Message 2 in thread
hello,
your problem is caused by mallfunction of mysql_character_set_name()
function for some mysql versions. You can patch qsql_mysq.cpp file,
function:
static QTextCodec* codec(MYSQL* mysql)
{
#if MYSQL_VERSION_ID >= 32321
QTextCodec* heuristicCodec =
QTextCodec::codecForName(mysql_character_set_name(mysql));
if (heuristicCodec)
return heuristicCodec;
#endif
return QTextCodec::codecForLocale();
}
or check, what your MySQL client function mysql_character_set_name()
returns.
Fanda
On Wed, 06 Dec 2006 10:17:26 +0100, Oleg Romanenko <oleg@xxxxxxxxxxxx>
wrote:
> Hello everyone,
>
> I have a MySQL database that uses Windows-1251 encoding. When I try to
> read values from the database into Qt QString or a QTableView, I get
> either question marks, or unreadable characters (if I init connection
> with SET NAMES 'cp1251')
>
> What is the right way to use MySQL database if the data contained in the
> DB is not English. Is there are any way not to use UTF8 for the
> database? Just set a default encoding to the connection?
>
> Best regards,
> Oleg Romanenko
--
[ signature omitted ]