I have a form that accepts text and is posted to the server.
我有一个接受文本的表单并发布到服务器。
If a user were to input a French character such as 'à', it will be read as 'Ã' by Classic ASP code and be stored as 'Ã' in a SQL Server 2005 database.
如果用户要输入法语字符(如“à”),它将被Classic ASP代码读作“Ô,并在SQL Server 2005数据库中存储为“Ô。
A similar affect happens to other accented characters. What's happening?
其他重音字符也会产生类似的影响。发生了什么?
3 个解决方案
#1
It's a problem of character encoding. Apparently your server and database are configured with charsets Windows-1252 or ISO-8859-1, and you're receiving UTF-8 data.
这是字符编码的问题。显然,您的服务器和数据库配置了charsets Windows-1252或ISO-8859-1,并且您正在接收UTF-8数据。
You should check that your server sends a Content-Type or a Content-Encoding header with values ending with "charset=iso-8859-1".
您应检查您的服务器是否发送Content-Type或Content-Encoding标头,其值以“charset = iso-8859-1”结尾。
I guess your server doesn't send the charset of the documents, and people with default configuration set to UTF-8 send UTF-8 characters which are stored as iso-8859-1 (or Windows-1252) in your database.
我猜你的服务器不发送文件的字符集,默认配置设置为UTF-8的人发送UTF-8字符,这些字符在数据库中存储为iso-8859-1(或Windows-1252)。
#2
See my answer here for the detail on what is likely happening.
请参阅我的答案,了解可能发生的事情的详细信息。
Utlimately you need to ensure the encoding used in the form post matches the Response.CodePage of the receiving page. You can configure the actual character set sent by a form by placing the accept-charset attribute on the form element. The default accept-charset is the documents char-set.
您需要确保表单帖子中使用的编码与接收页面的Response.CodePage匹配。您可以通过在表单元素上放置accept-charset属性来配置表单发送的实际字符集。默认的accept-charset是文档char-set。
What exactly do you have the ASP files codepages set to (both on the page containing the form and the page receiving the post)?
你有什么ASP文件代码页设置为(包含表单的页面和接收帖子的页面)?
What are you setting the Response.CharSet value to in the form page?
你在表单页面中将Response.CharSet值设置为什么?
#3
I have just gone around in circles trying to fix this once and for all in my old classic asp app which uses jquery ajax posts to store info in a database. Tried every combination with no luck..
我刚刚试图在我的旧经典asp应用程序中一劳永逸地解决这个问题,该应用程序使用jquery ajax帖子在数据库中存储信息。尝试每一个组合没有运气..
Ended up modifying any sql selects by using the stored proc mentioned here and magic happened. Data is still stored corrupted in the database, but is displayed correctly on the site.
通过使用这里提到的存储过程结束修改任何sql选择并且魔术发生了。数据仍然存储在数据库中,但在网站上正确显示。
#1
It's a problem of character encoding. Apparently your server and database are configured with charsets Windows-1252 or ISO-8859-1, and you're receiving UTF-8 data.
这是字符编码的问题。显然,您的服务器和数据库配置了charsets Windows-1252或ISO-8859-1,并且您正在接收UTF-8数据。
You should check that your server sends a Content-Type or a Content-Encoding header with values ending with "charset=iso-8859-1".
您应检查您的服务器是否发送Content-Type或Content-Encoding标头,其值以“charset = iso-8859-1”结尾。
I guess your server doesn't send the charset of the documents, and people with default configuration set to UTF-8 send UTF-8 characters which are stored as iso-8859-1 (or Windows-1252) in your database.
我猜你的服务器不发送文件的字符集,默认配置设置为UTF-8的人发送UTF-8字符,这些字符在数据库中存储为iso-8859-1(或Windows-1252)。
#2
See my answer here for the detail on what is likely happening.
请参阅我的答案,了解可能发生的事情的详细信息。
Utlimately you need to ensure the encoding used in the form post matches the Response.CodePage of the receiving page. You can configure the actual character set sent by a form by placing the accept-charset attribute on the form element. The default accept-charset is the documents char-set.
您需要确保表单帖子中使用的编码与接收页面的Response.CodePage匹配。您可以通过在表单元素上放置accept-charset属性来配置表单发送的实际字符集。默认的accept-charset是文档char-set。
What exactly do you have the ASP files codepages set to (both on the page containing the form and the page receiving the post)?
你有什么ASP文件代码页设置为(包含表单的页面和接收帖子的页面)?
What are you setting the Response.CharSet value to in the form page?
你在表单页面中将Response.CharSet值设置为什么?
#3
I have just gone around in circles trying to fix this once and for all in my old classic asp app which uses jquery ajax posts to store info in a database. Tried every combination with no luck..
我刚刚试图在我的旧经典asp应用程序中一劳永逸地解决这个问题,该应用程序使用jquery ajax帖子在数据库中存储信息。尝试每一个组合没有运气..
Ended up modifying any sql selects by using the stored proc mentioned here and magic happened. Data is still stored corrupted in the database, but is displayed correctly on the site.
通过使用这里提到的存储过程结束修改任何sql选择并且魔术发生了。数据仍然存储在数据库中,但在网站上正确显示。