Solved

Corrupted Display with UTF-8 characters and MSSQL database

Posted on 2006-07-16
2
345 Views
Last Modified: 2013-12-03
I have developed a website for a client that uses an MSSQL database to store the page data.  I have done this many times in the past without problem, but for this client, I am not having success.

The english pages render without any problems.  But he now has translated his site into hebrew, which we have encoded (hopefully) using UTF-8, and the information is not displaying at all.  Instead we see question marks on the screen.  As if that wasn't bad enough, we actually sometimes see the information correctly on the screen (perhaps after we rebooted, or something else, but both me and my client have successfully seen the pages rendered correctly without modifying the data or the website at least once).

An example of this can be found here:
http://www.nlpjerusalem.com/index.asp?lang=HE

Along the top row are all the menu choices.  The one or two that display in proper hebrew characters are due to the fact that they were entered as ESCape characters (e.g. &# and the the number, such as 1510 and a ;).

I am currently developing in MS Expression Web Designer (beta), but I can't think of how that could have an effect on the information.

I've checked the database, and everything is perfect there. I use an online editor to edit the data, but can also view it in MS Access 2000.

Any ideas how to solve this. I'm going crazy (as is my client) and I can't think of a solution.

Thank you for any solutions you can come up with.
0
Comment
Question by:Lev Seltzer
2 Comments
 
LVL 10

Accepted Solution

by:
slamhound earned 500 total points
ID: 17120003
You can use the server.encode command that will render the unicode characters into the HTML &#150 style.

On the other hand, you can use this procedure that will do the same thing but give you a bit more control:

Public Function c2u(CnText)
      For zzzz = 1 to Len(CnText)
        c = Mid(CnText, zzzz, 1)
        if ascw(c) > 192 then '  and ascw(c) < 33
           c2u = c2u & "&#x" & Hex(AscW(c)) & ";"
        else
           c2u = c2u & c
        end if
     Next
   End Function

Also, make sure your ASP code starts with:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

And that you have this at the beginning of your HTML pages:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
0
 

Author Comment

by:Lev Seltzer
ID: 17120441
Your function was interesting,but the line:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
was what was (apparently) needed to correct the situation. I put it on my pages, and then instantly began working.  I tried another computer, and I tried in Firefox, and everything is perfect.

Thank you for the quick response!  you've saved the day.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now