A form was submitted in the windows-1252 encoding

柔情痞子 提交于 2020-01-12 07:44:31

问题


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

A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element. @ http://localhost:8080/myapp/login

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

<meta http-equiv="Content-Type" content="text/html; charset=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.

What am I missing here?

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


回答1:


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.

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.

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



来源:https://stackoverflow.com/questions/14196687/a-form-was-submitted-in-the-windows-1252-encoding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!