开发者

Arabic QueryString problem (???? in the value)

开发者 https://www.devze.com 2023-01-04 02:44 出处:网络
I am sending an arabic value in a querystring, when retrieving it on the server, the value is erroneous and is replaced by quotation marks (????).

I am sending an arabic value in a querystring, when retrieving it on the server, the value is erroneous and is replaced by quotation marks (????). for example: http://server/mypage.aspx?qs=مرحبا the value of Reque开发者_如何学编程st.QueryString("qs") is ?????

Note that Response.Write('مرحبا') executes correctly.

Any idea about this querystring problem?

Thanks.


Just URL Encode the arabic string and it should work fine.

Edit: You must URL Encode the string before putting it in the querystring.

For instance, if you were to url encode the space character, it will appear as %20 in your querystring, like this:

http://foo.com/dosomething?param1=hello%20world

Then when you read param1 you URL Decode it, and you get the string "hello world"

You could also URL Encode every single character but for regular characters it's pointless.


I sent an Arabic text in my query string

Arabic QueryString problem (???? in the value)

and when I resieved this string it was Encoded

Arabic QueryString problem (???? in the value)

after Server.UrlDecode

 departmentName = Server.UrlDecode(departmentName);

it back again to arabic

Arabic QueryString problem (???? in the value)

so just use Server.UrlDecode(encodedString);

Hope this help you


I had a similar problem and solved it by putting the following line in my web.config file:

<globalization fileEncoding="windows-1256" 
    requestEncoding="windows-1256" responseEncoding="windows-1256"/>"

And this in the head section of my HTML page:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">


The Non english characters can't be passed without being encoded ,

so you need to encode the value before you redirect to the target page as follows:

string text="مرحبا";
text=Server.UrlEncode(text);
string url="http://server/mypage.aspx?qs="+text;
Response.Redirect(url);
0

精彩评论

暂无评论...
验证码 换一张
取 消