Link to home
Start Free TrialLog in
Avatar of robrodp
robrodpFlag for Mexico

asked on

javascript jquery and ms sql unicode incompatibility

I have developed a site (classic asp), it saves data in ms sql. At first it had no javascript to speak ok. I have updated the app to use jquery extensively thus javascript.

I am forced to use utf-8. Originally I used iso-8859-1, all was ok. the ms sql database stored and retrieved the data perfectly

Now The site uses unicode and and the data is stored with unicode and special characters are saved as 2  characters. This is unacceptable, it makes the site unusable

I have tried to use different collations in the tables to no avail.

When googling all I get is a confirmation f this issue between ms sql and  unicode.
 
Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robrodp

ASKER

It is nvarchar

Thx
UTF-8 is not unicode, you need conversion of UCS-2 to UTF-8.

There are several levels where this can go wrong:

1. The webserver announces an encoding in its HTTP header
2. The html pages might containn contradicting encoding information
3. the ODBC driver used to query MSSQL might translate from UCS-2 to ANSI already.

You need to get all of this working together, there is no single solution for this, you need to address all of the vectors, eg find out what the Server has set as default encoding, see how you set your html and determine how ODBC translates MSSQL data.

Absolute no gos are storing UTF-8 in SQL Server tables, T-SQL string functions work with UCS-2 Unicode encoding and many functions would not work on UTF-8 strings interpreted as UCS-2, eg comparsions with = operator or LIKE, substrings, etc.

Without knowing any of your code of JQuery and DB access its impossible to recommend anything.

Bye, Olaf.
Avatar of robrodp

ASKER

Working on this

Thx