Sometimes i face the following problem :
string txt = con.Request.Params["Par_name"].ToString();//the original par value is arabic text
I get the following result!!
��� ������ ������� �����
What’s the reason to this problem and how to get the original arabic text ??
When you send string via url parametres, even via ajax and its utf-8 to avoid conflicts you must encode it with the javascript functions like the
encodeURIComponent. Encode only the part of the value, not the parameters and the full url ! When then read the parameters on code behind they usually be UrlDecode by default, but if they not, do it manually.For example the code from https://stackoverflow.com/a/10968848/159270 will be:
I did not include this encode on the previous answer because usually they are not send string as parameters, but variables, and because the answer was not focus on this detail.
You can also read : http://xkr.us/articles/javascript/encode-compare/