3

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.

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,

Richard
  • 31
  • 1
  • 2

3 Answers3

8

It's been URL-encoded. You just need to URL-decode it.

See also:

Community
  • 1
  • 1
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
4

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.

Daniel DiPaolo
  • 55,313
  • 14
  • 116
  • 115
2

Looks URL encoded, to me.

In javascript:

decodeURIComponent("%C3%A9%C3%A0%C3%A9%C3%A0");
sorpigal
  • 25,504
  • 8
  • 57
  • 75