PDA

View Full Version : Ext accentuation problem



rafaelrp
15 Aug 2012, 6:18 AM
Hello !

I have a combo with some names, one of this names have accentuation, ""FRĀNCES PERIN", but when i select the name in combo, the combo value returns "FRÂNCES PERIN".

How i can fix this problem?


Thanks ! ~o)

skirtle
15 Aug 2012, 12:00 PM
From what you're describing, I'd say that the problem is the data in your store has the accented character encoded as an HTML entity. Take a look at the source of the data and see whether it's coming through with HTML entities.

rafaelrp
15 Aug 2012, 12:06 PM
Humm, probably is this, here is my json result
{"condutor":"FRÂNCES PERIN","id_condutor":"113697"}


i need to get this name encoded from ajax?

skirtle
15 Aug 2012, 2:46 PM
The accent shouldn't be HTML encoded in the JSON. JSON uses UTF-8 so the character can be included without using an escape sequence. If, for some strange reason, you have a problem including non-ASCII characters in your JSON you can escape it using the \uXXXX notation instead, which is the appropriate escape sequence for the contents of JSON strings.

rafaelrp
12 Sep 2012, 6:42 AM
Sorry, but i don't understand this concept of notation, can you explain how i can correct this problem?


Thanks! ~o)

loiane
12 Sep 2012, 6:45 AM
Also, make sure you have the following code inside your html head tag:


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

rafaelrp
12 Sep 2012, 6:55 AM
I have utf-8 configurated on my index, the combo brings the names correctly but only when i select the valuefield of the combo brings the name like '&atilde'.

@loiane sou do brasil tb ;)

Thanks! ~o)

skirtle
12 Sep 2012, 9:12 AM
Using your own example, what you have currently is this:


{"condutor":"FR&Acirc;NCES PERIN","id_condutor":"113697"}

This contains an HTML entity, which it shouldn't. The accented character can just be written literally, in UTF-8.


{"condutor":"FRĀNCES PERIN","id_condutor":"113697"}

If, for some reason, you have difficulty including non-ASCII characters in your JSON you could instead use the escape sequence:


{"condutor":"FR\u00C2NCES PERIN","id_condutor":"113697"}

The sequence \u00C2 is the correct escape sequence for a JSON string and when the JSON is read it will end up equivalent to including the character directly, as in the previous example.

The key thing to understand here is what ends up in your combobox's store. In your current code the record will have a field value that contains an HTML entity. What you need is for the record to contain the accented character itself.

metalinspired
12 Sep 2012, 11:12 AM
What is providing data for your combo?

rafaelrp
12 Sep 2012, 11:21 AM
an Ajax DataStore with dinamic data from a php sql query.

Thanks ~o)

metalinspired
12 Sep 2012, 11:48 AM
if you've sanitized your data in some step it might have ran htmlentities() (http://php.net/manual/en/function.htmlentities.php)

rafaelrp
13 Sep 2012, 12:18 PM
Here is the data..



$arrJson[$i]['desc'] = utf8_encode(htmlentities($row['desc']));

metalinspired
13 Sep 2012, 9:53 PM
Here is the data..



$arrJson[$i]['desc'] = utf8_encode(htmlentities($row['desc']));


Try using htmlspecialchars() (http://php.net/manual/en/function.htmlspecialchars.php) instead of htmlentities() (http://php.net/manual/en/function.htmlentities.php).

rafaelrp
14 Sep 2012, 3:01 AM
It worked !


Thanks! ~o)