Silverlight / WPF - Chinese Characters are getting grabled in my silverlight application

Asked By sandy narang
05-Aug-10 05:36 AM

Hi All,

I am having a tough time in sending the Chinese Characters through my silverlight application to other server.

Assume that I have a url which is having Chinese Characters in it. I am usnig webclient now and once the request reached at server. it is getting grabled as ‘’. Pleae find the code below -

string strName= "您好";
url = adminUrl + "DataUpdateHelper?name=" + strName;
WebClient webClient = new WebClient();
webClient.Encoding = Encoding.UTF8;
Uri uri = new Uri(url);
webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(ReadEventCompleted);
webClient.OpenReadAsync(uri);

Does anyone knows the solution for this?



Thanks,
Sandy
  onur replied to sandy narang
21-Aug-10 07:47 AM
Hi,
I have same problem with Turkish characters. Did you find any solution?
  sandy narang replied to onur
21-Aug-10 10:46 PM
Hi onur,

There would be two solution which i found for the same -
1. You need to UrlEncode the chinese characters. Sometime we have to encode it two times and decode it once. Like this:
  string strName= HttpUtility.UrlEncode(string);
 Don't forget to use the corresponding decode method on the other end.

2. Instead of using the Get Request please use Post request. it will solve your problem.

I am using second approach for my solution.

Hope this will be helpful for you.

Thanks,
Sandy
Create New Account