views:

144

answers:

2

I am looking to create an ASP.net page that will have a control like GridView or Repeater and the data to be displayed in this page can be either unicode or Utf-8 . I am really struggling to display languages like Hebrew and some asian languages.

How do I show any type of language on the ASP.net page?? I have tried the meta tag option and <@ Page> option to set encoding but its not working. What am I missing??

+1  A: 

Make sure that Response.Charset = UTF-8.

andrewbadera
+1  A: 

Ideally, this should all be handled transparently by your environment. Unfortunately, "the environment" also hands you several tools with which to mess things up.

Two things need to happen. Your server needs to know what encoding it is supposed to send to the client and the browser needs to know what that encoding is. Typically, IIS is set to emit UTF-8, which is exactly what you want, period.

If you view the headers of one of your pages via something like http://web-sniffer.net/, you can see what your server is telling the browser it is sending. You can and should also send along an HTML meta tag specifying the same encoding (UTF-8).

You can also specify the encoding in web.config and presumably, in the ASP.Net page declaration. However, this should be redundant.

There is no place you need to specify this encoding in any of your server side writers, as long as you use the ones handed to you by the current http context.

There are likely more issues surrounding the right-to-left languages that may require additional tweaks.

Ishmael