views:

29

answers:

3

I have a situation.

I have a label in ASP.NET 2.0(C#). The label should display a dutch language text that is "Sähköpostiosoite", I tried setting the Label.Text both from markup and code-behind but what I see in the browser response is "Sähköpostiosoite".

Originally assigned string "Sähköpostiosoite" get replaced with "Sähköpostiosoite". I have no idea why this happens can you please help me diagnose the problem ??

A: 

You need to set the HTTP header:

Content-Type: text/html; charset=UTF-8

and/or add HTML markup:

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

More info here.

Martin Wickman
This happens at the server-side.
this. __curious_geek
And you are absolutely positively sure that changing the browser encoding does not solve this? At a glance, it looks like the generated bytes is correct UTF-8 and that it is your browser that has problems showing it.
Martin Wickman
A: 

Have you checked the encoding of the HTML? In IE you can quickly switch between encodings by right-clicking and changing the active encoding from the Encoding sub-menu (there's probably a way to do it in FF too but I don't know it). If changing the encoding (e.g. to UTF-8) fixes the text then you should specify the encoding via a HTTP header (which can set site-wde using the <globalization /> element in web.config or via HTTP <meta /> element in the page HTML.

See this for info on the <globalization /> element: http://msdn.microsoft.com/en-us/library/hy4kkhe0.aspx.

Daniel Renshaw
A: 

We found the problem.

The asp.net page is generated by our inhouse code-generator. We did not supply the encoding format while saving the file to disk. We rectified this by telling the code-gen to use UTF8 encoding while saving the file and it resolved the issue.

this. __curious_geek