views:

442

answers:

2

We have translated one of our pages to french and all the html within the page displays flawlessly. That said, there is a javascript table (ext js) and the accented characters are not displaying correctly. The page is encoded UTF-8 in the HTML meta tags, but when I look inside FireBug, I see the following:

Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7

I'm guessing the problem is related to the ISO-8859-1 having worked its way back in. Does anyone know why the page itself would display fine, but the text inside the javascript component wouldn't? Do you somehow specify the encoding separately for the javascript files?

A: 

It's possible that the ext. JS file strips out unrecognised characters as a security precaution.

The "Accept-Charset" header can be specified in a number of places, including as an attribute in certain HTML elements. Have you performed a search for Accept-Charset (case insensitive) in the offending file?

Rushyo
I searched for Accept-Charset, but didn't find anything in the related files. I'm stumped on how to solve it.
Could you provide a link to the code?
Rushyo
Ext does not "strip out unrecognised characters"
bmoeskau
I assumed ext meant external :]
Rushyo
+2  A: 

The Accept-Charset tag gives a set of encodings that are accepted -- if all the data sent is encoded UTF-8, then don't worry about it.

Can you elaborate on exactly what is happening?

  1. You say "javascript table" -- I presume you are constructing an HTML table in JS and placing it in the DOM? Please elaborate, especially w.r.t. any character conversions. Are you building HTML text or building with DOM elements with attributes?
  2. Where does the JS get its data? If with AJAX, have you verified the Encoding for that page?
  3. Does the JS use encode() or decode()? Those don't handle UTF-8 correctly.


EDIT:

  • Type the URL to the JS code in your browser, and look at "Page Info" to see its encoding. I'll bet it is ISO-8859-1, which would explain the header problems.

  • Next, check the encoding of the AJAX data. If it's dynamically created you can:

    1. Enable "Show XMLHttpRequests" in FireBug's console,
    2. Load on your base HTML page,
    3. Open the FireBug console tab,
    4. Expand the AJAX GET/POST request and open the Response sub-tab,
    5. Check the Encoding for the data, and fix as needed.

BTW, I'm having similar problems and haven't entirely ironed out the issues (still not sure the source data isn't badly encoded).

NVRAM
It is an EXT JS gridPanel table. The table is constructed with JS and being placed into the DOM. The JS code is being called onLoad() and resides in a separate file. The JS file has the french characters defined inside of it when the table is created. There is AJAX being used for obtaining the contents of the table, but the problem is actually present in the table headings which are defined before AJAX gets involved. I'm not sure if EXT JS uses encode or decode, but I'm not sure why they would do that to the table heading. Thanks!
Oh, I thought "ext JS" was "External JavaScript" but now I realize/recall it's code from **www.extjs.com**. D'oh.
NVRAM
I didn't realize that the files themselves are encoded. I figured out in my code editor where the encoding is set. Changing the file encoding to UTF-8 resolved the issue. Thanks!!!