错误的字符集在ASP经典的通过AJAX加载 [英] Wrong charset in ASP classic loaded via AJAX

查看:165
本文介绍了错误的字符集在ASP经典的通过AJAX加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题的ASP的经典网页内容的一部分动态加载。我使用AJAX动态页面加载,这取决于下拉列表中选择选项。生成包含一些标签包含下拉菜单内的下拉列表中选择和文字。标签是常数EN codeD在UTF-8和包含一些西欧重音符号,并选择文本从数据库中加载,包含重音字符太多,但有codeD的ANSI。标签被设置为UTF-8,但它会影响页面的只有第一次加载,COS的都放在一起页。在选择其他选项后,AJAX填充元素和它加载标签很好,但选择文字搞砸了,所以我想AJAX犯规加载文本第二等次的编码。解决方法是更改​​常量和集标签文本 <%Response.Charset的=窗口1252%>是beeing加载第一次页面上。 现在,我想找到这个更好的办法,prefferably在Ajax响应到它的所有设置为UTF-8或Windows-1225,或设置页面上的每个元素有不同的编码与阿贾克斯。我甚至尝试替换从ASP经典之作,它的工作原理的功能,但同样也需要对每个新的重音字母等代替。任何帮助AP preciated! :)

I have issue with dynamic loading of part of content on ASP classic page. I use AJAX to load on page dynamically, depending on dropdown selected option. Generated contains some Labels for containing dropdowns and option text inside of dropdowns. Labels are constants encoded in UTF-8 and contain some western European accented characters, and option texts are loaded from database, contain accented characters too but are coded in ANSI. tags are set to utf-8 but it affects only first load of page, cos its all put together on page. After selecting other options, AJAX fills with elements and it loads labels well but options text is messed up, so i guess AJAX doesnt load up encoding with text second and etc. times. Work-around was to change label text in constants and set <% Response.Charset = "windows-1252" %> on page that is beeing loaded first time. Now, i want to find better way for this, prefferably in AJAX response to set it all to UTF-8 or windows-1225, or to set each element on page to have different coding with ajax. I even tried Replace function from ASP classic, it works , but again it needs for each new accented letter other replace. Any help appreciated! :)

推荐答案

我觉得要解决编码问题的最好办法是切换到UTF-8。它不仅带走处理特殊字符在你自己的语言的头痛,但pretty的多少(我的理解UTF-8)所有语言!

I think the best way to solve encoding issues is to switch to utf-8. Not only does it take away the headache of handling special characters in your own language, but pretty much (as I understand utf-8) all languages!

首先,在HTML头下面的元标记。

First, include the following meta-tag in the HTML head.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

您还需要设置UTF-8所涉及到的所有ASP-文件的顶部。

You will also need to set UTF-8 at the top of all asp-files that are involved.

response.codepage = 65001
response.charset = "utf-8" 

确实注意到,虽然该字符发送到并从ASP-页面(例如经由一种形式)将PTED为UTF-8跨$ P $。内部脚本引擎字符串存储为单code。 确保始终如一的数据另存为UNI code在数据库中。

Do note though that characters posted to and from your asp-pages (via a form for example) will be interpreted as utf-8. Internally in the script engine strings is stored as unicode. Make sure that consistently save the data as unicode in the database.

阅读的回答这个问题进行更深入的信息

Read the answer to this question for more in-depth information

这篇关于错误的字符集在ASP经典的通过AJAX加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆