BLOB data gets encoded as utf8! (First post incomplete)

BLOB data gets encoded as utf8! (First post incomplete)

am 24.08.2010 20:47:45 von Andreas Iwanowski

Hello everyone!

I am using an MFC unicode project that uses ODBC to access a MySQL
5.1.50 database via the MySQL ODBC 5.1.6 driver.
character_set_connection is set to utf8 (Which I believe is the default
for the driver)
One of the tables contains two LONGBLOB columns, and the table default
charset is utf-8 (since the application is unicode).

However, when inserting into the LONGBLOB columns via an INSERT
statement, the data gets corrupted/modified because is incorrectly UTF-8
encoded.

My insert statement (simplified) does this:

INSERT INTO _table_ (Desc, Data) VALUES ('...', '_blobdata_');

I have also tried the _binary introducer
(http://dev.mysql.com/doc/refman/5.1/en/string-syntax.html)

INSERT INTO _table_ (Desc, Data) VALUES ('...', _binary'_blobdata_');

I'm escaping 0x00, 0x22, 0x27, and 0x5C, which are the only four that
MySQL requires to be escaped per documentation for BLOB fields, and
according to the MySQL docs columns of any BLOB type use no character
set.=20

Here is the problem: I found that, for example, 0xFF gets modified to
0xC3BF, which is in fact the UTF8 encoding for ASCII/Binary 0xFF.

Needless to say the data becomes useless. I did, however, determine that
the data is already "corrupted" in the myodbc.log file that the driver
outputs if the option is set, so there is likely a problem with the
driver settings or with the statement itself.

I cannot be the first one to encounter this issue, so maybe if you have
an idea (or a solution would be even better! :) then please let me know.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg