I have a really annoying problem:
I had a string éàéà which I passed in the serialize function. It gave me the string %C3%A9%C3%A0%C3%A9%C3%A0.
开发者_JS百科How can I come back (either in JS or PHP) to éàéà to save the string properly in my MySQL UTF-8 encoded database?
thanks in advance,
It's been URL-encoded. You just need to URL-decode it.
See also:
- PHP URL decoding
- JavaScript URL decoding
Javascript's native decodeURI
function or the related decodeURIComponent
function should do it. W3Schools has some example code for decodeURI
and for decodeURIComponent
. If you're decoding only stuff generated by jQuery's serialize
function, then the latter is probably more appropriate but if you are decoding an entire URI, then the former would be more appropriate.
Looks URL encoded, to me.
In javascript:
decodeURIComponent("%C3%A9%C3%A0%C3%A9%C3%A0");
精彩评论