How to read Arabic character in ASP.Net that is stored in VARCHAR field

1.4k views Asked by At

In my database there is a field which stores Arabic names. Field type is VARCHAR.

When I run SELECT statement in SQL Editor to get records then it shows me value ãÇ äÇá which is actually ما نال

Problem is when I am displaying this value in ASP.Net, it is displayed as ÒÃ õÃß. I have changed page encoding to UTF-8 but no luck. How do I display Arabic names properly in ASP.Net that are stored in VARCHAR field? Please note field type cannot be changed in database.

2

There are 2 answers

0
Frank Martin On BEST ANSWER

Found the solution. Use

KeepOrgMultibyte=1

in Sybase connection string in web.config. Example given below.

<add name="Sybase" connectionString="Data Source='192.168.0.70';Port=9100;UID='myuser';PWD='mypassword';Database='mydatabase';KeepOrgMultibyte=1;"/>
8
Luaan On

Your collation is wrong - you're storing arabic-collated data in a non-arabic-collated varchar column.

However, you should be able to force the correct collation just for the select by using the collate keyword. A quick sample:

select [Text] collate Arabic_CI_AI_KS_WS from YourTable;

If this doesn't help, the data has already been inserted incorrectly in the table. That's a bit of a problem.

First, you have to find the proper mis-encodings that lead to where you are now. The problem is, it's pretty likely you're actually dealing with a MS SQL-specific encoding, which probably will not be easy to handle in .NET.