ASP Classic 中的字符集
这里似乎有很多关于此问题的报道,但我找不到任何可以解决我遇到的问题的内容。
我有一个 MySQL 数据库,我正在尝试用它执行各种嵌套查询,这对我来说是新的。我在 ID 字段上使用 GROUP_CONCAT 来返回查询返回的行的 ID 值列表。
在任何其他字段上使用它都会返回所需数据的漂亮整洁的数组,但在 ID 字段上我得到了 Gobbledegook!这个ID字段上没有设置排序规则,因为dB不允许我这样做,该字段是一个自动递增字段,类型设置为int(10),所以我想这就是原因。
我问我的网络主机为什么会收到这些冗长的内容,得到的答复是:
“当转换为字符串时,ASP 对字符集做出了假设。MySQL 结果以 UTF-8 格式返回,而不是像它假设的那样以 Windows-1521 格式返回。默认。”
所以,我开始搜索这个并在 StackExchange 上遇到了这个问题; 经典 ASP - 如何转换 UTF -8 字符串转换为 UCS-2?
我尝试运行那里建议的函数,但它只是将繁琐的内容变成了问号。返回的页面位于:http://hartnollguitars.co.uk/test_search。 asp?search=gibson%2008
我想也许我正在使用该函数转换错误的字符集或从错误的字符集转换,但恐怕我不知道如何以确定我正在处理哪个。
无论如何,帮助显示这些结果将不胜感激。
SQL 查询是:(简化)
results3.Open "SELECT * FROM (SELECT *, GROUP_CONCAT(id) as ItemList, count(id) as Variants FROM products WHERE item LIKE '%"& replace([searchterm]," ","%") &"%' GROUP BY item) AS UnknownVar LIMIT 40", conn, 3, &H0001
此处的输出示例: http://hartnollguitars .co.uk/test_search.asp?search=gibson%2008
There seems to be a lot of coverage of this on here, but I can't find anything that cracks the problem I'm having.
I have a MySQL Database which I am trying to do various nested queries with, which is new to me. I am using GROUP_CONCAT on the ID field to return a list of the ID values of the rows which are returned by the queries.
Using this on any other field returns a nice neat array of the data required, but on the ID field I am getting Gobbledegook! There is no collation set on this ID field, because the dB won't let me do so, the field is an auto-incrementing field with type set as int(10), so I guess this is why.
I asked my web hosts why I'm getting the gobbledegook, and the response was:
"When converting to a string ASP makes assumptions over the character set. The MySQL results are returned in UTF-8, not Windows-1521 as it assumes by default."
So, I started searching for this and came across this question on StackExchange;
Classic ASP - How to convert a UTF-8 string to UCS-2?
I have tried running the function suggested in there, but it just turns the gobbledegook into question marks. The page returned is here: http://hartnollguitars.co.uk/test_search.asp?search=gibson%2008
I'm thinking that perhaps I am converting to or from the wrong character set with that function, but I'm afraid I don't know how to determine which I'm dealing with.
Anyway help to display these results would be appreciated.
The SQL Query is: (simplified)
results3.Open "SELECT * FROM (SELECT *, GROUP_CONCAT(id) as ItemList, count(id) as Variants FROM products WHERE item LIKE '%"& replace([searchterm]," ","%") &"%' GROUP BY item) AS UnknownVar LIMIT 40", conn, 3, &H0001
Example of outputs here: http://hartnollguitars.co.uk/test_search.asp?search=gibson%2008
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正在对此进行另一次尝试(之前的答案已删除)。请尝试将代码页指令添加到页面,并将 META 字符集设置为 UTF-8,如下所示。下面的代码应该发送并告诉浏览器将页面解释为 UTF-8。
希望这有帮助!
I'm taking another shot at this (previous answer removed). Please try to add the codepage directive to the page, and also set META charset to UTF-8, as below. The code below should send and tell browsers to interpret the page as UTF-8.
Hope this helps!