Amine Mostefaoui
Amine Mostefaoui

Reputation: 63

Get existing arabic data from SQL Server database

My boss asked to use an old SQL Server database and build a new application. When I open it, I found that all the Arabic data appear like this

http://i60.tinypic.com/14lraee.png

Firstname |


ÚÌæØÚÌæØ |

Èä ÍãíÏÉ |

ÈæÒÇäÉ |

ÈæÔÑæÑ |

the column type is already nvarchar

The old application use the same database and retrieve normally all the data arabic and non arabic i dont have the code source of this old application

How can I convert the existent data to appear normally ?

I tried both SQL command like

SELECT UNICODE(@nstring) 

or

NCHAR(UNICODE(@nstring)) 

and C# convert method like

https://social.msdn.microsoft.com/Forums/vstudio/en-us/49c55ea4-83c4-4b3b-81ef-d3a54ddf919e/how-do-i-convert-utf8-format-to-unicode-format?forum=netfxbcl

I tried open it with SQL server management studio i tried changing character set , i tried changing the Collection SET but no luck !

Upvotes: 0

Views: 1499

Answers (2)

Amine Mostefaoui
Amine Mostefaoui

Reputation: 63

  string data = File.ReadAllText("d.txt", Encoding.GetEncoding("windows-1256"));
            File.WriteAllText("d.txt", data, Encoding.UTF8);
            string data2 = File.ReadAllText("t.txt", Encoding.GetEncoding("ISO-8859-6"));
            File.WriteAllText("t.txt", data, Encoding.UTF8);  

Upvotes: 0

Richard Schneider
Richard Schneider

Reputation: 35477

From your clues, I am guessing that the strings in the database are NOT Unicode, but are encoded as some Code Page, perhaps Code Page 1256 Windows Arabic

If this is the case you then have to Convert Between Legacy Encodings and Unicode

Upvotes: 4

Related Questions