- Home /
WWW.UnEscapeURL and WWW.EscapeURL cannot swap back?
I using UnEscapeURL with encoding big5 is work, input "%BC%D6 " return "樂".
But i want to EscapeURL with encoding big5 is not correct. input "樂" return "%e6%a8%82"
Debug.Log(WWW.UnEscapeURL("%BC%D6", System.Text.Encoding.GetEncoding("big5")));
Debug.Log(WWW.EscapeURL("樂", System.Text.Encoding.GetEncoding("big5")));
Output:
樂
%e6%a8%82
It mean EscapeURL with encoding is not work?
Answer by Bunny83 · Apr 17, 2019 at 01:47 AM
I guess this is not really an issue of EscapeURL not working correctly, but actually an issue of how your source code file is encoded. Since you put that character as a string literal into the source file and you probably have the file encoded with UTF8, the character is probably encoded as it is. "%e6%a8%82" is the correct UTF8 encoding.
By the way the actual URL encoding standard does allow encoding arbitrary data in an URL. However character data should be UTF8 encoded since any other encoding may not be interpreted correctly. Just try it with an online URL encoder / decoder. "%BC%D6" can't be decoded at all while "%e6%a8%82" decodes to 樂 and 樂 encodes to "%e6%a8%82".
Yes, i know that "%e6%a8%82" is the correct with UTF8 encoding things. But if i use EscapeURL with encoding this is not work or no point?
$$anonymous$$y source file enorded is UTF-8 with BO$$anonymous$$ (VS code show me). I tried don't let the script encoding to affect the result:
Debug.Log(WWW.EscapeURL(WWW.UnEscapeURL("%BC%D6", System.Text.Encoding.GetEncoding("big5")), System.Text.Encoding.GetEncoding("big5")));
It should be work? Apparently the outcome is still utf-8 encoding "%e6%a8%82".
oh, i see. but i working the target endpoint is encoding in an URL. is old things... anyway, i tried another online encoder / decoder with encoding format its work. so i have a question on WWW.EscapeURL with encoding.
Your answer
![](https://koobas.hobune.stream/wayback/20220612195612im_/https://answers.unity.com/themes/thub/images/avi.jpg)