[Mono-devel-list] System.Data.OracleClient

Eduard Nesiba eda at monetplus.cz
Fri May 7 10:03:40 EDT 2004


Hello Jörg,

In OCI exists functions

OCINlsGetInfo(dvoid *hndl, OCIError *errhp, OraText *buf, size_t buflen,
ub2 item)

with 'EvnHandle' and 'NLS_CHARACTER_SET'
we can get client NLS charset

and

OCINlsNameMap( dvoid *hndl, oratext *buf, size_t buflen, const oratext *srcbuf, 
word flag)

With 'OCI_NLS_CS_ORA_TO_IANA' we can get client ISO charset name.

Have you any idea where is better place to call this functions
and set this attribute for current connection to be avialable
in OciDefineHandle and OciStatementHandle?

PS: Can you commit my patch to CVS without charset changes?

Thanks.

Eduard


Jörg Rosenkranz wrote:

> Hello Eduard,
>
>     -----Original Message-----
>     *From:* Eduard Nesiba [mailto:eduard.nesiba at monetplus.cz]
>     *Sent:* Thursday, May 06, 2004 9:08 PM
>     *To:* Jörg Rosenkranz
>     *Subject:* Re: [Mono-devel-list] System.Data.OracleClient
>
>>
>>Does System.Data.OracleClient under MS.NET behave the same way?
>>  
>>
>     Yes, it does. 
>
> Then this would be OK to commit. Otherwise we would break 
> compatibility between MS.NET and Mono.   
>
>>>- statement char set conversion
>>>    
>>>
>>
>>Please do not convert back to Encoding.Default. The encoding 
>>Oracle uses is defined by the environment variable NLS_LANG.
>>Encoding.Default requires this variable to be set to the right encoding
>>for the current system. Using the current implementation you 
>>simply set
>>	
>>	NLS_LANG=AMERICAN_AMERICA.UTF8
>>
>>and character conversion works regardless of the encoding the
>>local system uses. If we want a really clean implementation we have
>>to choose the encoding for statements and results according to NLS_LANG.
>>
>>  
>>
>     OK. But if we want output/input in other code page (we are using
>     ISO8859-2) we must do this char set conversion.
>     Tested on Linux a Windows and everything fine according NLS_LANG
>     settings.
>
>      
>
> We are using ISO-8859-1 on our systems to handle german umlauts. This 
> works fine because UTF8
> is only used as encoding between Oracle and the client. Using 
> DefaultEncoding the setting of
> NLS_LANG depends on the local encoding settings. It has to be set 
> to EE8ISO8859P2  on your
> systems and  WE8ISO8859P1 on our systems to allow non ASCII 
> characters. Using the current
> implementation it can always be set to UTF8 regardless of the 
> character set the OS uses.
>  
> The best way to handle this would be to check NLS_LANG and use the 
> configured encoding
> in System.Data.OracleClient. I don't know if there is an easy way to 
> do the mapping of Oracle
> character set names to Mono encodings other than a big mapping table.  
> Maybe something like:
>  
> string enc;
>  
> switch ( oracleEncoding ) {
>     case "WE8ISO8859P1":    enc = "iso-8859-1"; break;
>     case "EE8ISO8859P2":    enc = "iso-8859-2"; break;
>     ...
>     default: enc = "utf-8"; break;    // UTF8 as fallback
> }
>  
> Encoding oracleEncoding = Encoding.GetEncoding(enc);
>  
> You can find the Oracle char set names in the "Database Globalization 
> Support Guide".
>  
> Joerg.
>  






More information about the Mono-devel-list mailing list