views:

106

answers:

3

Hi guys, I've got a multilingual site, that allows users to input text to search a form field, but the text goes through Javascript before heading off to the backend.

Special chars like "欢" are being properly handled in Firefox, but not in any version of IE.

Can someone help me understand what's going on?

Thanks!

A: 

Ensure your characters and your page are both using UTF-8 encoding.

Diodeus
+1  A: 

Some browsers default differently, set the default encoding for your site forcefully by utilizing the meta tag for encoding. As here:

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

UTF-8 may not be what you're looking for but is the most likely. Testing, go to view->character encoding in firefox and set it manually. By knowing which one works, you will know which to set it to. A list of schemas here: http://tlt.its.psu.edu/suggestions/international/web/tips/declare.html and more here: http://tlt.its.psu.edu/suggestions/international/bylanguage/index.html

Chisum
+1  A: 

You might find it useful to add the accept-charset attribute to your form. This specifies to the browser what character-set the server accepts. Your JS should follow this and send it in that format.

Some other things that can affect the way IE handles character encoding:

  • Specifying the correct doctype (ie, standards vs. "compliance" modes).
  • The Content-Type header sent by the server; I believe most browsers adhere to the header over the meta-tag, so if your server is specifying ISO-8859-1 and your page specifies UTF-8 there will be some confusion.
  • The format of the Content-Type header; some "modern" browsers (specifically FF) accept utf8 as an alias of utf-8. IE does not, and falls-back to ISO-8859-1. (This comes from painful personal experience! ;)

Character-sets are a real pain. You need to ensure that all the components are talking the same "language" front-to-back - that includes both storage and communication.

The next step to track down what is going on is to have your server code log the headers for your JS request to be sure that the encoding matches what you're expecting.

digitala