8

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)

Community
  • 1
  • 1
arahant
  • 2,203
  • 7
  • 38
  • 62
  • 2
    Examine the HTTP headers sent to/from the server (e.g. using Firebug.) Also see the notes on encoding [in the HTML specification](http://www.w3.org/TR/html4/charset.html). – McDowell Jan 07 '13 at 13:17
  • The response header has Content-Type: text/html;charset=ISO-8859-1 (even though the in html it is UTF-8; I assume this something to do with the web server itself). More importantly however the request header only has Accept-Encoding: gzip, deflate – arahant Jan 07 '13 at 14:03
  • 1
    FYI: The `Accept-Encoding` is the compression type. See [headers in the HTTP spec](https://tools.ietf.org/html/rfc2068#section-14). But it looks like you have a configuration issue in the web server. – McDowell Jan 07 '13 at 14:49

1 Answers1

11

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.

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
  • 2
    +1, Also for some trivia: The message says a form was submitted in "windows-1252" because that's the actual encoding browsers use when ISO-8859-1 is the declared encoding. – Esailija Jan 07 '13 at 15:23
  • 1
    To summarize, setting the content-type of page to utf-8 did not fix anything. Setting accept-charset=utf-8 on the form element itself did. – arahant Jan 08 '13 at 06:50