Said AKHROUF
Said AKHROUF

Reputation: 245

Transform SQL Server text from French to Arabic

I have an existing SQL Server database where text is stored in Arabic. The default database collation is FRENCH_CI_AS, but the application uses Arabic. Displaying the data with ASP is not a problem, but I want to create a new database using UTF-8!

Text sample as it's stored in database :

ترأس وزير السكن والعمران ووزير الأشغال العمومية للجنة التقنية لمراقبة البناء

enter image description here

How I can transform text to get clear Arabic text in the database ?

Is there a solution using Excel? http://en.file-upload.net/download-10245297/test.xls.html

Upvotes: 1

Views: 465

Answers (3)

Said AKHROUF
Said AKHROUF

Reputation: 245

I share a little java project (with dependencies). This project loads table data first and formats strings. The generated EXCEL worksheet can now imported using SSMS.

Java solution :

String charabia = "ترأس وزير السكن والعمر" ;
try {
     String utf8String = new String(charabia.getBytes(), "UTF-8");
} catch (UnsupportedEncodingException e) {
}

My project download link : here

Upvotes: 0

John Taylor
John Taylor

Reputation: 446

The strings need to be stored in the database as NVARCHAR instead of VARCHAR. This allows the database to store UTF16 encoded strings instead of ASCII with a CodePage. Of course this will double the amount of storage needed for the database.

From the screen shot it looks like the string is UTF8 being displayed as if it was ASCII and there does not appear to be a way to tell SQL this detail.

Upvotes: 0

ako
ako

Reputation: 179

first of all use nvarchar() for type of Data in your Tables then when inserting data into your tabel insert like this

string Query="insert into tablename(columnName) values(N'value')...";

Upvotes: 2

Related Questions