Extract Chinese text from Query string
I need to extract Chinese characters from the query string in an ASP.NET web application. When I tried it, I get "????" instead of the actual text. I know I need to decode it with UTF-8 but its does not work. I have used:
String text = System.Web.HttpUtility.UrlDecode(Request.QueryString["text"], System.开发者_如何学PythonText.Encoding.UTF8);
but I get "???" back from the operation.
Please help.
There are two cases.
1st Case where your URL is real in chinese, the only function that get it is the Request.RawUrl (and not the Request.QueryString["text"]) From Request.RawUrl you need manually get your Chinese text from text=ελληνικασανκινεζικα.
2nd Case where you have first Encode your URL string before you send it. In this case the code I use is
String text = Server.UrlDecode(Request.QueryString["text"]);
Hope this help.
Note: If you try to make test with Google Chrome, then what you type on url chrome is encode/decode automatically by browser and you are not see what actual you send. Try to use ie, for make your test.
精彩评论