Oracle and Unicode

C

ccidral

Hello all!

I am writing an application that connects to an Oracle 9i database
using
OracleClient managed provider. There's a table with a field of
NVARCHAR2
type, named TEXT, and another field of VARCHAR2 type, named COMMENT.
The
application do insert text values into both fields correctly, even if
high
code point Unicode characters are inserted into the TEXT field.
Unfortunately, those special characters are not returned correctly;
instead,
the "¿" character is returned in place of them; only characters within
ASCII
code range are returned as expected. I think there is some kind of
conversion from high Unicode code points to ASCII codes at the moment
of
data return, somewhere in the OracleClient classes. In fact, I don't
know
what's happening here. Following are the database parameters:

PARAMETER VALUE
------------------------------
----------------------------------------
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS .,
NLS_CHARACTERSET WE8ISO8859P1
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY $
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_RDBMS_VERSION 9.2.0.3.0


And these are the session parameters:

PARAMETER VALUE
------------------------------
----------------------------------------
NLS_LANGUAGE BRAZILIAN PORTUGUESE
NLS_TERRITORY BRAZIL
NLS_CURRENCY Cr$
NLS_ISO_CURRENCY BRAZIL
NLS_NUMERIC_CHARACTERS ,.
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD/MM/RR
NLS_DATE_LANGUAGE BRAZILIAN PORTUGUESE
NLS_SORT WEST_EUROPEAN
NLS_TIME_FORMAT HH24:MI:SSXFF
NLS_TIMESTAMP_FORMAT DD/MM/RR HH24:MI:SSXFF
NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
NLS_TIMESTAMP_TZ_FORMAT DD/MM/RR HH24:MI:SSXFF TZR
NLS_DUAL_CURRENCY Cr$
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE

I also tried to change the NLS_LANG in the registry, as we can see
Microsoft's instructions in
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q322158,
NLS_LANG
Settings section:

NLS_LANG changed from BRAZILIAN PORTUGUESE_BRAZIL.WE8MSWIN1252 to
BRAZILIAN
PORTUGUESE_BRAZIL.AL16UTF16


But, when doing that, an exception is thrown when trying to connect to
the
database:

System.Exception: Could not create an environment: OCIEnvCreate
returned -1.
at System.Data.OracleClient.DBObjectPool.GetObject(Object
owningObject,
Boolean& isInTransaction)
at
System.Data.OracleClient.OracleConnectionPoolManager.GetPooledConnection(Str
ing encryptedConnectionString, OracleConnectionString options,
OracleConnection owningObject, Boolean& isInTransaction)
at
System.Data.OracleClient.OracleConnection.OpenInternal(OracleConnectionStrin
g parsedConnectionString, Object transact)
at System.Data.OracleClient.OracleConnection.Open()
at Unicode.RecordSource.GetAll(DataTable table) in
C:\Testes\Unicode\RecordSource.vb:line 39
at Unicode.MainForm.LoadData() in
C:\Testes\Unicode\MainForm.vb:line 179


In my connection, I included the UNICODE parameter:
DATA
SOURCE=ORCL_TESTE;UNICODE=TRUE;UID=TESTE_UNICODE;PWD=TESTE_UNICODE

I also tried using ODP.NET, and did'nt work too.


Yet, I searched the entire web for someone who had the same problem,
but I
found no hope.

Can anyone take me out of this trouble?

Best regards,
 
P

Paul Clement

On 10 Feb 2004 17:34:31 -0600, (e-mail address removed)-dot-br.no-spam.invalid (ccidral) wrote:

¤ Hello all!
¤
¤ I am writing an application that connects to an Oracle 9i database
¤ using
¤ OracleClient managed provider. There's a table with a field of
¤ NVARCHAR2
¤ type, named TEXT, and another field of VARCHAR2 type, named COMMENT.
¤ The
¤ application do insert text values into both fields correctly, even if
¤ high
¤ code point Unicode characters are inserted into the TEXT field.
¤ Unfortunately, those special characters are not returned correctly;
¤ instead,
¤ the "¿" character is returned in place of them; only characters within
¤ ASCII
¤ code range are returned as expected. I think there is some kind of
¤ conversion from high Unicode code points to ASCII codes at the moment
¤ of
¤ data return, somewhere in the OracleClient classes. In fact, I don't
¤ know
¤ what's happening here. Following are the database parameters:
¤
¤ PARAMETER VALUE
¤ ------------------------------
¤ ----------------------------------------
¤ NLS_LANGUAGE AMERICAN
¤ NLS_TERRITORY AMERICA
¤ NLS_CURRENCY $
¤ NLS_ISO_CURRENCY AMERICA
¤ NLS_NUMERIC_CHARACTERS .,
¤ NLS_CHARACTERSET WE8ISO8859P1
¤ NLS_CALENDAR GREGORIAN
¤ NLS_DATE_FORMAT DD-MON-RR
¤ NLS_DATE_LANGUAGE AMERICAN
¤ NLS_SORT BINARY
¤ NLS_TIME_FORMAT HH.MI.SSXFF AM
¤ NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
¤ NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
¤ NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
¤ NLS_DUAL_CURRENCY $
¤ NLS_COMP BINARY
¤ NLS_LENGTH_SEMANTICS BYTE
¤ NLS_NCHAR_CONV_EXCP FALSE
¤ NLS_NCHAR_CHARACTERSET AL16UTF16
¤ NLS_RDBMS_VERSION 9.2.0.3.0
¤
¤
¤ And these are the session parameters:
¤
¤ PARAMETER VALUE
¤ ------------------------------
¤ ----------------------------------------
¤ NLS_LANGUAGE BRAZILIAN PORTUGUESE
¤ NLS_TERRITORY BRAZIL
¤ NLS_CURRENCY Cr$
¤ NLS_ISO_CURRENCY BRAZIL
¤ NLS_NUMERIC_CHARACTERS ,.
¤ NLS_CALENDAR GREGORIAN
¤ NLS_DATE_FORMAT DD/MM/RR
¤ NLS_DATE_LANGUAGE BRAZILIAN PORTUGUESE
¤ NLS_SORT WEST_EUROPEAN
¤ NLS_TIME_FORMAT HH24:MI:SSXFF
¤ NLS_TIMESTAMP_FORMAT DD/MM/RR HH24:MI:SSXFF
¤ NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
¤ NLS_TIMESTAMP_TZ_FORMAT DD/MM/RR HH24:MI:SSXFF TZR
¤ NLS_DUAL_CURRENCY Cr$
¤ NLS_COMP BINARY
¤ NLS_LENGTH_SEMANTICS BYTE
¤ NLS_NCHAR_CONV_EXCP FALSE
¤
¤ I also tried to change the NLS_LANG in the registry, as we can see
¤ Microsoft's instructions in
¤ http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q322158,
¤ NLS_LANG
¤ Settings section:
¤
¤ NLS_LANG changed from BRAZILIAN PORTUGUESE_BRAZIL.WE8MSWIN1252 to
¤ BRAZILIAN
¤ PORTUGUESE_BRAZIL.AL16UTF16
¤
¤
¤ But, when doing that, an exception is thrown when trying to connect to
¤ the
¤ database:
¤
¤ System.Exception: Could not create an environment: OCIEnvCreate
¤ returned -1.
¤ at System.Data.OracleClient.DBObjectPool.GetObject(Object
¤ owningObject,
¤ Boolean& isInTransaction)
¤ at
¤ System.Data.OracleClient.OracleConnectionPoolManager.GetPooledConnection(Str
¤ ing encryptedConnectionString, OracleConnectionString options,
¤ OracleConnection owningObject, Boolean& isInTransaction)
¤ at
¤ System.Data.OracleClient.OracleConnection.OpenInternal(OracleConnectionStrin
¤ g parsedConnectionString, Object transact)
¤ at System.Data.OracleClient.OracleConnection.Open()
¤ at Unicode.RecordSource.GetAll(DataTable table) in
¤ C:\Testes\Unicode\RecordSource.vb:line 39
¤ at Unicode.MainForm.LoadData() in
¤ C:\Testes\Unicode\MainForm.vb:line 179
¤
¤
¤ In my connection, I included the UNICODE parameter:
¤ DATA
¤ SOURCE=ORCL_TESTE;UNICODE=TRUE;UID=TESTE_UNICODE;PWD=TESTE_UNICODE
¤
¤ I also tried using ODP.NET, and did'nt work too.
¤
¤
¤ Yet, I searched the entire web for someone who had the same problem,
¤ but I
¤ found no hope.
¤
¤ Can anyone take me out of this trouble?
¤

It isn't clear to me how you are retrieving the data. Are you using an Oracle package/stored
procedure?


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top