Issues with foreign languages and SQL server

Izi

Izi

Soldato
Joined
9 Dec 2007
Posts
2,718
I need to store greek, russian, polish, french and english in a DB.

I have set the fields to nvarchar.

When I save some greek (Κατάδυση για αρχαρίους) using a form to the db it stores in the DB as:

Κατάδυση για αÏχαÏίους

If i then copy and past the greek directly in the db, it shows correctly in the DB but when pulled out on the page it looks like:

?at?d?s? ??a a??a?????

What the heck?

Going mad :/
 
I should explain that I am having to use classic ASP to pull the data out... dont ask!

I have tried charsets utf-8 and iso etc... so confused.
 
OK, using SQL profiler, by the time the text gets to SQL it looks like this:

UPDATE event SET C_Skip = N'n',C_Partner = N'n',C_Price=0.00,C_Label1=N'7.Diving Baptism - Experienced',C_Label2=N'7.Κατάδυση για αÏχαÏίους',C_Label3=N'',C_Label4=N'7.Il battesimo subacqueo - Esperti',C_Label5=N'7.Bautizo de submarinismo – Expertos',C_Label6=N'7.Дайвинг Ð´Ð»Ñ Ð¾Ð¿Ñ‹Ñ‚Ð½Ñ‹Ñ… нырÑльщиков',C_Label7=N'7.Chrzest dla nurków - Zaawansowani',C_Label8=N'7.Baptismo de Mergulho – Experientes ',C_Label9=N'7.Κατάδυση για πεπειÏαμÎ*νους',C_Value1=N'7.Diving Baptism - Experienced',C_Value2=N'7.Κατάδυση για αÏχαÏίους',C_Value3=N'',C_Value4=N'7.Il battesimo subacqueo - Esperti',C_Value5=N'7.Bautizo de submarinismo – Expertos',C_Value6=N'7.Дайвинг Ð´Ð»Ñ Ð¾Ð¿Ñ‹Ñ‚Ð½Ñ‹Ñ… нырÑльщиков',C_Value7=N'7.Chrzest dla nurków - Zaawansowani',C_Value8=N'7.Baptismo de Mergulho – Experientes ',C_Value9=N'7.Κατάδυσ· για πεπειÏαμÎ*νους' WHERE C_ID=2407

Using UTF-8 charset on the page. Do i have to do something with the actual comand in asp?
 
OK two things for anyone who stumbles upon this:

1) You need Response.CodePage = 65001 for utf coding before calling insert
2) Make sure you have N'yourstring' in the update string.

Now does any clever chap know how to convert the goblegook above which is stored in SQL to the correct characters?
 
Hi,

In the page you are sending the form data and retrieving to put in the db (assuming you are taking it from a form?):

<%@ LANGUAGE=VBScript codepage=65001 %>
<% Response.CharSet = "UTF-8" %>

It should then store it in the DB using SET fieldname = N'retrieved form content here', if the data in the db is like above it's not stored it correctly, retrieving it should be simple (just make sure it's UTF-8 in the page to display it) :)
 
Hi,

In the page you are sending the form data and retrieving to put in the db (assuming you are taking it from a form?):

<%@ LANGUAGE=VBScript codepage=65001 %>
<% Response.CharSet = "UTF-8" %>

It should then store it in the DB using SET fieldname = N'retrieved form content here', if the data in the db is like above it's not stored it correctly, retrieving it should be simple (just make sure it's UTF-8 in the page to display it) :)

Hey thanks,

that was my findings after a little digging. It appears .NET takes care of this for you as I've not had this problem before?

So does anyone know how to get my messed up uni code: Συμφωνώ να δημοσιευτεί το όνομά μου δίπλα στην επιλογή της δÏαστηÏιότητάς μου

back in its correct form? Interestingly if the above is pulled out of DB and set as utf-8 it does display properly.
 
Back
Top Bottom