0

I have a WCF service. It fetches data from database that is populated by another device it saves some device specific information in a database column. The device saves information in Chinese. I don't have any control on that device. The data saved in db column is something like this:

ACC? ???? ?????? ???? TCP???? ????????? ?? ???? ???? ????

How can I get Chinese characters instead of question marks? Any quick help will be highly appreciated.

I have tried to use Chinese Encoding.GetEncoding("gb2312").GetString() method but it still returns same string with question marks in it

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
sharpthnkr
  • 38
  • 4
  • You need to use `NVARCHAR(n)` column datatype in your SQL Server table to handle Unicode strings like Chinese – marc_s Apr 06 '15 at 09:51
  • The current column type is already NVARCHAR. Even If I check the stored values in the column they are same as shared in my question :( – sharpthnkr Apr 06 '15 at 10:43
  • If the column data in database has `???..` then you have to correct the application that is saving the data in Database. – Sukanya1991 Apr 06 '15 at 11:05
  • I don't have any control on the application that saves information in database. Also for your information there is another application that is accessing that database and is displaying the information correctly. Unfortunately I have access to database but no access to the applications at all. – sharpthnkr Apr 06 '15 at 13:02
  • What I understood is that when you run query from your machine you get junk data, but the server actually has correct data. Right? Which OS are you using? Is there any other table where you have Chinese data and are you able to see them properly? – Sukanya1991 Apr 06 '15 at 13:47

1 Answers1

0

You need to make sure you use correct encoding throughout. It's likely that at some point the text is encoded into ASCII, in which case any non-English chars (plus numbers and some punctuations) will be converted to ?.

Try using UTF-16 everywhere. Depending on the dialect, you may need to look at UTF-32. See UTF8, UTF16, and UTF32 for additional info.

Community
  • 1
  • 1
oleksii
  • 35,458
  • 16
  • 93
  • 163
  • Thanks for responding even in database I can see the weird characters with instead of chines. The database column type is NVARCHAR – sharpthnkr Apr 06 '15 at 10:44
  • Also to let you know I am using ADO.NET to retrieve the information and then LINQ to SQL to populate the information. When I check the datatable by debugging in designer it still does not have the correct information it returns same string as above shared string :( – sharpthnkr Apr 06 '15 at 10:46