表单是以Windows-1252编码提交的 [英] A form was submitted in the windows-1252 encoding

查看:630
本文介绍了表单是以Windows-1252编码提交的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Firefox网络控制台的JS标签中收到以下警告( Ctrl + Shift + K

I am getting the following warning in the JS tab of the Firefox web console (Ctrl + Shift + K)


表单是在windows-1252编码中提交的,不能编码
所有Unicode字符,因此用户输入可能会损坏。为了避免这个
问题,应该更改页面,以便在
UTF-8编码中提交表单,通过将页面本身的编码改为UTF-8或者通过指定accept-charset = utf-8。 @
http:// localhost:8080 / myapp / login

html确实使用utf-8编码,如下:

The html does use the utf-8 encoding explicitly, like so:

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

html(实际上是Freemarker模板)文件以前在Windows机器上。因此,我使用recode实用程序(如此处)将它们重新编码为utf-8。但我仍然看到同样的警告。

The html (actually Freemarker templates) files were previously on a Windows machine. So I recoded them to utf-8 using the recode utility as suggested here. But I still see the same warning.

我在这里缺少什么?

没有警告或错误在Chrome的开发者工具实用程序( Ctrl + Shift + I

There is no warning or error in the Chrome's developer tools utility (Ctrl + Shift + I)

推荐答案

基于注释,很明显,服务器在HTTP头中指定编码为ISO-8859-1。您无法在HTML中为文档本身覆盖此内容。不过,您可以使用 accept-charset = utf-8 /forms.html#h-17.3> form 标记指定表单数据提交的字符编码。

Based on the comment, it seems obvious that the server specifies the encoding as ISO-8859-1 in HTTP headers. You cannot override this in HTML for the document itself. You can, however, use the accept-charset=utf-8 attribute in the form tag to specify the character encoding of the form data submission.

要更改HTTP头,您需要在服务器级别执行某些操作。这可能意味着创建或编辑.htaccess文件或其他文件。

To change the HTTP headers, you need to do something at the server level. This may mean creating or editing a .htaccess file, or something else.

Accept-Encoding 头与此无关。它不指定字符编码,但指定数据的传输编码。

P.S. The Accept-Encoding header is unrelated to this. It does not specify character encoding but a transfer encoding for the data.

这篇关于表单是以Windows-1252编码提交的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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