views:

74

answers:

1

Using javascript, I'm setting the src of an iframe to an URL passing a GET variable, urlencoded with unescape( encodeURIComponent( message ) ).

With IE, this works the first time I load the iframe.The utf-8 characters, as the var_dump($_GET) reveals server-side, are okay. But next calls, all I get is garbage.

On the other hand, if I just send in the message variable, without any escaping, the first time I set the iframe, the var_dump($_GET) shows the characters are wrong. But next calls, the variable is correctly set!!

Any idea of whats going on?

+1  A: 

Do the following:

  1. Use these JS functions for encoding / decoding your string to / from UTF8.

  2. Save your code files with UTF8 without BOM encoding using any advanced text-editor / IDE like Notepad++.

shamittomar
At times like these, I wish that encoding scheme was called WTF-8 or WTF-I-8-This :p. (+1)
karim79
All the js and php is saved as UTF-8 without BOM.Using that js, i got the same result.The first time i use it to generate the query string, it works.The next times, it doesnt.Btw..It just happens in IE..Firefox works like a charm.
Jose
Ok, i've noticed that it doesnt matter if the first request includes utf-8 or not.So, making a first a "fake" request to the same url *with no query string at all* , makes the real request correctly send the utf-8 encoded characters...Dirty hack
Jose