Problem using / displaying special characters from Oracle db in .Net application

I have a C # .Net application that accesses data from a commercial application supported by Oracle db. Several fields in the commercial application database (declared as varchar2 (n)) contain special characters. For example, the apostrophe "smart quote." The commercial client application displays these characters correctly, but my application displays them as an inverted question mark. The Oracle character set is "WE8ISO8859P1".

My application reads a commercial database using System.Data.OracleClient.OracleDataAdapter converted to a table via DataSet.Tables. Tables are converted to objects, and the corresponding fields are stored as rows.

If I examine (in the debugger) the data in the DataSet immediately after reading from db, and special characters are already displayed incorrectly. I cannot figure out how to examine the data as hexadecimal bytes to see what actually is, and I'm not sure what I should look for.

I also noted that Toad displays characters as inverted question marks.

One aspect of our application writes these records to a separate table in our own database; when this happens, special characters are modified and then displayed as blocks instead of inverted question marks.

I can provide additional information if necessary. Thanks for any help!

+3
source share
2

, :

(, ), , , .
  • , . / Word Excel, , .

  • . WE8ISO8859P1, WE8MSWIN1252. - , .

  • SYS.UTL_RAW.CAST_TO_RAW ( ), "BF" ( ). , , . , / BF. , Word - "", .

  • dump ( ) - , SYS.UTL_RAW.CAST_TO_RAW . . () db.

dbs. , () db ( ). , , . , . , , .; -)

, !

+2

WE8ISO8859P1 , UTF8.

2

1) Oracle .NET(ODP.NET). , / Microsoft System.Data.OracleClient, WE8ISO8859P1 unicode. ODP.NET

, ODP (, , , )

2) : ( ) String ( ). , .

-

Encoding e = Encoding.GetEncoding("iso-8859-1");
foreach(DataRow row in dataset.Tables["MyTable"])
{
    if (!row.IsNull("MyByteArrayField"))
        row["MyStringField"] = e.GetString((row["MyByteArrayField"] as byte[]));
}
+2

Source: https://habr.com/ru/post/1714229/


All Articles