- Home /
Text Encoding, WWW.UnEscapeURL
I'm having weird problems with the WWW.UnEscapeURL()
We're working on a french translation, but special characters don't show up. but as we all know changing the script to UTF-8 enables special characters, so when I print "" in my code on screen, it works.
Now the peculiar thing happens when I ask text from the server. I get the text from a php page and it encodes my text with rawurlencode (as suggested in another question on this site)
but when I use www.UnescapeURL(www.data), my special characters don't show up, the font I use is Unicode and works because when I print www.UnEscapeURL(www.datat)+"" on screen, the shows up, but in my log the special characters don't get decoded.
so my guess is that the %.. aren't aligned
I'll finish with a small example of what I encounter in my Debug.Log
Mais%20aussi%20un%20oiseau%20un%20peu%20b%EAte%2C%20n%27est-ce%20pas%3F
Translates To:
Mais aussi un oiseau un peu bte, n'est-ce pas?
so the %EA doesn't decode to
I also tried encoding it with System.Text.Encoding.ASCII, just to know what I'd get, and the missing characters get replaced by ?-marks
Answer by sanryoga · Jan 25, 2010 at 11:18 AM
After some intensive testing and experimenting, we've found that the rawurlencode was the problem
we just encoded via WWW.escapeURL and saw that there was a difference with rawurlencode throught testing it seems that (in php) urlencode(utf8_encode($string)); is the encoding you should use.
The strange thing is, I thought rawurlencode used to work when I was using 2.5, or was it just my imagination?
Answer by jonas-echterhoff · Jan 25, 2010 at 11:19 AM
How was the text encoded before you escaped it to get the string "Mais%20aussi%20un%20oiseau%20un%20peu%20b%EAte%2C%20n%27est-ce%20pas%3F"?
The use of a single %EA to represent an accented character seems to indicate it was encoded in Windows-1252, not in UTF-8, which should generate two substitution characters. Try encoding the text in UTF-8 before escaping.
Your answer
Follow this Question
Related Questions
degrees celcius symbol in unity 2 Answers
Umlaut shown as ?? in GUILayout.Button 3 Answers
UTF-8 for foreign language characters on GUI 2 Answers
UTF-8 Support in Unity iPhone 1.6? 2 Answers
GUI.PasswordField "•" makes "?" 1 Answer