Mysql – ASP, MySQL and UTF-8

asp-classicMySQLodbcutf-8

First of all, I've read almost all topics about this. I've tried all advices but I couldn't solve this problem.

Here is the thing. I use Classic ASP and MySQL for a project. Everything just fine. If I write (an example) Response.Write("ĞŞÜÇÖİ") it works like a charm. But if that string comes from database, I see "ÄÅÜÇÖİ" instead of "ĞŞÜÇÖİ". When I look this with phpMyAdmin it's ok.

I use Dreamweaver CS6. I save all pages Unicode (UTF-8). I've written Session.CodePage = 65001, Response.CodePage = 65001, Response.Charset = "utf-8" in an include file that every page has it at the top. I've written meta charset utf-8. I use ODBC 5.2 x64 driver and my connection string has charset:UTF8;. And all MySQL settings utf-8 (tables, fields, everything).

Well I don't want to use other encodings, charsets. What am I doing doing wrong? It seems, it's about database. What is the problem?

Best Answer

You need to specify the character set in the connection string using the charset parameter; see the MySQL ODBC doco. e.g. add "charset=utf8;" "charset=ucs2;" to your connection string.

Edited: I finally got a chance to run a simple test harness on this, and it does indeed fail with charset=utf8. However, since VBScript is running internally with UCS2, I gave it a try with charset=ucs2 and it works fine. NB: page is still set to send all output as UTF-8, it's just that VBScript is pulling data from an ODBC connection using UCS2. Job is done :)