views:

31

answers:

1

Hi All,

I need to extract chinese characters from the query string in a 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 doesnot work. I have used

String text = System.Web.HttpUtility.UrlDecode(Request.QueryString["text"], System.Text.Encoding.UTF8);

but I get back "???" from the operation.

Please help

A: 

There is 2 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.

Aristos
I cant use case 2 as the request coming from the client browser is the first Request. So I am not setting the values in query string. I will try with case 1.
A Junkie
@A Junkie Remember that you need manual to get the text out... search for ? symbol, then for the TEXT= etc...
Aristos
A Junkie
I got it. You need to install Chinese language pack and then use `String text = Server.UrlDecode(Request.QueryString["text"]);' to extract the text. Thanks
A Junkie