views:

835

answers:

2

How can I show an nvarchar column that stores unicode data (Entered with the zawgyi1 font) in a classic ASP web page?

When I retrieve and write the value to the page, it shows "?????". I set my ASP page's content type of UTF-8 with the following meta tag:

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

Unfortunately, the text is still rendered as "?????".

Any suggestions or ideas on how to display unicode values in a classic ASP page?

+2  A: 

What about your codepage definition at the top of your page?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
jammus
Thanks a lot ! It works for me. I just add that script at my page. Thanks a lot! I can't reply immediately 'coz I can't be online that days. Thanks.
RedsDevils
+6  A: 

The Content-Type meta header informs the browser to treat the content sent as a UTF-8 encoded text stream. It doesn't ensure that the stream sent is actually UTF-8. To handle UTF-8 correctly you need to do 3 things:-

  1. Ensure your static content is saved in a UTF-8 compatible encoding.
  2. Ensure your dynamic content is encoded to UTF-8.
  3. Inform the client that the content is UTF-8 encoded.

Item 1 requires either that you actually save the ASP file as a UTF-8 encoded file or that all your static content in the file is within the ASCII character range (0-127). Note if you save as UTF-8 then all your server-side script must use characters within the ASCII character range.

Item 2 requires that the Response.CodePage property is set to the UTF-8 code page 65001, you can do this in code or by adding the attribute CODEPAGE=65001 to the <%@ %> declarations on the first line of the ASP file. If you do it in code you must set it before any calls to Response.Write.

Item 3 requires that the Content-Type header contains the charset=UTF-8 qualifier. As you are already doing you can do this with the META header. Personally I find that to be a bit of kludge, I prefer to use Response.Charset = "UTF-8" in code. This places the qualifier on the true Content-Type HTTP header.

AnthonyWJones
Thanks AnthonyWJones your Item2 work with my problem. Thanks!
RedsDevils
On our site even though we had the meta element added in the html I still had to add the Response.Charset, thanks Anythony.
Pacifika