PDA

View Full Version : UTF-8 in DB but accent not working with Ext.data.store



pp2
15 Jan 2011, 9:21 AM
Hi all,

I have a problem with accent.
I want to get"Société" but get Soci?t? (which ends up to a "null" for extjs)

If I invoke the PHP directly from the browser I have "Société" ok, then the DB (in utf-8) and PHP are fines:
http://.../x.php?action_file&readFromFilter //<== this give me "Société"With Ext.data.store the accent is not passing, even at the PHP level...
var store_x = new Ext.data.Store({ //<== this give me "Soci?t?"
url: "x.php",
baseParams: {action_file: "readFromFilter"},
reader: new Ext.data.JsonReader({
totalProperty: "results",
root: "rows"
},[{name: "T1_TOTEXT"}])
});

even doing an echo at the PHP level I get Soci?t?

The only difference I see is on the way the PHP is invoked.
Header request from direct PHP invocation (url): <== this give me "Société"


User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; it; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Cookie PHPSESSID=61279mne0t1vk28qn1m4v0nvj1
Pragma no-cache
Cache-Control no-cache

Header request with Ext.data.store (then with ajax): <== this give me "Soci?t?"
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; it; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
X-Requested-With XMLHttpRequest
Content-Type application/x-www-form-urlencoded; charset=UTF-8
Referer http://n.n.n.n:89/x.php (http://n.n.n.n:89/db2web2/x2ndFile/filterEdit_LOOKOA_LANGDICT.php)
Content-Length 51
Cookie PHPSESSID=61279mne0t1vk28qn1m4v0nvj1

Any idea?
Thanks

valititi
15 Jan 2011, 2:57 PM
1. for big or strange values, try to set method to POST..
2. for the serverside, use htmlentities($yourAccentedValue) or similars funcs
3. and for client side there are similar functions in javascript... escape, encode, urlencode...
hope this may help.

pp2
15 Jan 2011, 3:14 PM
valititi,

The point 2. for the serverside, use htmlentities($yourAccentedValue) works! that resolves the issue.

Your are brilliant!
Thanks a lot

valititi
15 Jan 2011, 9:57 PM
please delete "You are brilliant" from your post ! I am just a rookie in Ext !
you can also delete "a lot" :-)
Keeping only "Thanks" will be correct & enough :-)