Skip to main content

Microsoft Silverlight

Answered Question Problem with swedish characters åäö in webclientRSS Feed

(0)

deslo
deslo

Member

Member

31 points

44 Posts

Problem with swedish characters åäö in webclient

I have a problem with saving data. I use a webclient to communicate with the server, and each time I send something with a å ä or ö in it, that character is converted when it reaches the server. I've tried setting webClient.Encoding but there aren't that many alternatives, and nothing works. How do I solve this?

mbaker3
mbaker3

Member

Member

168 points

71 Posts

Re: Problem with swedish characters åäö in webclient

 Have you tried using HttpUtility.HtmlEncode()? I know thats not exactly what its for but at least the data will be preserved during transfer.

Alternatively it may be worth while to look into the Encoding class (System.text.Encoding). I haven't used it before but converting a compatible format may work.

MarkMonster
MarkMonster

Contributor

Contributor

5220 points

1,046 Posts

Re: Problem with swedish characters åäö in webclient

That's basically because of the Encoding. Do those characters exist in the encoding used?

Mark Monster - MCPD Enterprise
http://mark.mymonster.nl
Silverlight and Expression Insiders UG

Dont forget to click "Mark as Answer" on the post that helped you.

SharpGIS
SharpGIS

Contributor

Contributor

3387 points

611 Posts

Answered Question

Re: Re: Problem with swedish characters åäö in webclient

Your problem could also be at the server end though...

Usually using UTF8 should work for those characters. Just make sure you use UTF8 in both ends for encoding and decoding.

--
/Morten | blog - twitter
Please click on "Mark as Answer" if this answered your question.

deslo
deslo

Member

Member

31 points

44 Posts

Re: Re: Problem with swedish characters åäö in webclient

Could someone post an example of this encoding and decoding? I can't seem to make it work.

Code at client side: 

 

string wUrl = String.Format("caller={0}&proc={1}", wCaller, wProc);
wUrl = "http://localhost:50899/slproxy.aspx?" + wUrl;          

webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webclient_DownloadStringCompleted);
webClient.DownloadStringAsync(new Uri(wUrl, UriKind.Absolute));

  

 Code at server side:

  

Request.ContentEncoding = Encoding.UTF8;
string caller = Request.QueryString.Get("caller");
string proc = Request.QueryString.Get("proc");
 

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities