urlencode and special characters
Posted by: SeikimaIII
Posted on: 2009-02-28 15:46:00
I'm making a small web app using AJAX to retrieve file names from the server and display them on the web page.
The problem I have is it seems urlencode and rawurlencode do not work correctly.
Here is an example:
- I use urlencode on the filename "02 - Bagatelle in A Minor, WoO 59, _Für Elise_.mp3".
- I use Javascript to retrieve the data through AJAX which then uses decodeURIComponent to get back to the original string.
- I get an error stating the string is a malformed URI.
I did some digging and found this website: http://www.the-art-of-web.com/javascript/escape/ which I used to test the strings coming from my webpage.
Putting the string "02 - Bagatelle in A Minor, WoO 59, _Für Elise_.mp3" into the aforementioned webpage and using their encodeurl and rawencodeurl functions I get these strings:
urlencode:
02 - Bagatelle in A Minor, WoO 59, _Für Elise_.mp3
where ü is encoded as % C3 % BC (without the spaces)
rawurlencode:
02 - Bagatelle in A Minor, WoO 59, _Für Elise_.mp3
where ü is encoded as % C3 % BC (without the spaces)
Using these functions in my own php script gives me these strings:
urlencode:
02 - Bagatelle in A Minor, WoO 59, _Für Elise_.mp3
where ü is encoded as % FC (without the space)
rawurlencode:
02 - Bagatelle in A Minor, WoO 59, _Für Elise_.mp3
where ü is encoded as % FC (without the space)
Does anyone have any ideas if I might be doing something incorrectly or if there is something that I need to add to have these strings encoded in a way that javascript can decode them?