Barnacle
23rd January 2009, 14:49
Anyone know if it's possible to use other encodings than UTF-8 in things like QSqlQuery?
My problem is that my MySQL database has a mixture of encodings. For example, some columns use the normal UTF-8 encoding and some use ascii_bin or latin1 (I can not change this). When I run a query against an ascii_bin column I get "illegal mix of collations" errors presumably because Qt is trying to convert everything to UTF on the back-end and the database doesn't like that.
So I'm wondering if there any way to force a query to use a different encoding than UTF? It would be nice if the string QVariant had a way to forcibly set the character encoding but I don't know how to do it if it's possible. Either that or if QSqlQuery had a way to set the encoding of the bound values.
My problem is that my MySQL database has a mixture of encodings. For example, some columns use the normal UTF-8 encoding and some use ascii_bin or latin1 (I can not change this). When I run a query against an ascii_bin column I get "illegal mix of collations" errors presumably because Qt is trying to convert everything to UTF on the back-end and the database doesn't like that.
So I'm wondering if there any way to force a query to use a different encoding than UTF? It would be nice if the string QVariant had a way to forcibly set the character encoding but I don't know how to do it if it's possible. Either that or if QSqlQuery had a way to set the encoding of the bound values.