ASP、MySQL 和 UTF-8

ASP, MySQL and UTF-8(ASP、MySQL 和 UTF-8)

本文介绍了ASP、MySQL 和 UTF-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我已经阅读了几乎所有关于此的主题.我已经尝试了所有建议,但我无法解决这个问题.

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

事情就是这样.我在一个项目中使用 Classic ASP 和 MySQL.一切都很好.如果我写(一个例子) Response.Write("ĞŞÜÇÖİ") 它就像一个魅力.但如果该字符串来自数据库,我会看到ÄÅÜÇÖİ"而不是ĞŞÜÇÖİ".当我用 phpMyAdmin 看这个时,没关系.

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.

我使用 Dreamweaver CS6.我保存所有页面 Unicode (UTF-8).我在包含文件中编写了 Session.CodePage = 65001, Response.CodePage = 65001, Response.Charset = "utf-8" ,每个页面的顶部都有它.我已经编写了元字符集 utf-8.我使用 ODBC 5.2 x64 驱动程序,我的连接字符串有 charset:UTF8;.以及所有 MySQL 设置 utf-8(表、字段、所有内容).

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?

推荐答案

需要使用charset参数指定连接字符串中的字符集;请参阅 MySQL ODBC 文档.例如添加 "charset=utf8;" "charset=ucs2;"到您的连接字符串.

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.

已我终于有机会对此运行一个简单的测试工具,它确实因 charset=utf8 而失败.但是,由于 VBScript 是在 UCS2 内部运行的,所以我尝试使用 charset=ucs2 并且它工作正常.注意:页面仍然设置为以 UTF-8 格式发送所有输出,只是 VBScript 正在使用 UCS2 从 ODBC 连接中提取数据.工作完成:)

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 :)

这篇关于ASP、MySQL 和 UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:ASP、MySQL 和 UTF-8

基础教程推荐