Ibn-Tashfin
Ibn-Tashfin

Reputation: 13

.NET can't read arabic character from oracle with charset "WE8ISO8859P1"

I have developed a web based application using C# with ASP.NET that reads from oracle database.. I've deployed it before and it was working perfectly.. but this time I'm deploying it with an oracle database that its character set is " WE8ISO8859P1 " .. and there are some data in Arabic stored in the database..

The problem is: The .NET reads Arabic characters corrupted (some thing like this : " ÇáÝÑÚ ÇáÑÆíÓí "), but when using SQL PLUS it reads Arabic normally;

I've searched and found this OTN: Database Character set

Any solution to make it read data correctly?

Upvotes: 1

Views: 3487

Answers (2)

Diego
Diego

Reputation: 18379

Have you tried using Unicode=true in the connection string? See this: http://msdn.microsoft.com/en-us/library/2d7h4ycx(v=vs.80).aspx

If that doesn't work, try reading it as binary using OracleDataReader.GetBytes, then encoding using codepage 1256 (Arabic). Something like:

var buffer = new byte[4096];
int bytesRead = oracleReader.GetBytes(columnIndex, 0, buffer, 0, buffer.Length);
String value = new String(new System.Text.Encoding(1256).GetChars(buffer, 0, bytesRead));

Upvotes: 1

Justin Cave
Justin Cave

Reputation: 231861

It sounds like your database is configured incorrectly.

The ISO-8859-1 character set does not support Arabic data (I'm assuming that since you only mentioned the database character set that you're storing the data in CHAR or VARCHAR2 columns rather than NCHAR or NVARCHAR2). You cannot properly store Arabic data in CHAR or VARCHAR2 columns in a database where the database character set is WE8ISO8859P1. You would need to change the database character set to something that supports Arabic data in order to properly store Arabic data in CHAR or VARCHAR2 columns. Alternately, if your national character set supports Arabic, you could store the data in NCHAR or zNVARCHAR2` columns but that may entail application changes to support these data types.

Upvotes: 1

Related Questions