Page 1 of 1

OracleConnection.Unicode property

Posted: Fri 16 Jan 2009 18:54
by Alladin
What does this property do and when should I / should I not use it?

All strings in .NET are Unicode, what's a point to have this parameter then?
Are there any performance penalties/benefits for read/write data?

Could you please answer, when Unicode better be true:

a) Server character set is unicode UTF8 (NLS_CHARACTER=AL32UTF8)

b) Server character set is unicode UTF16 (NLS_CHARACTER=AL32UTF16)

c) Server character set is single byte encoding (f.e. NLS_CHARACTER= WE8MSWIN1252)

Thank you in advance,
Lex

Posted: Mon 19 Jan 2009 11:03
by Shalex
The Unicode property defines the charset that will be used at the network level for string transferring. The choice of this option has influence on the amount of conversions in the program and the possibility of data loss. If the Unicode property is set to true, UTF8 is used at the network level. Otherwise, the charset from regional settings of Windows is used.
a) If Unicode=true, the following scheme is implemented:
UTF8 (stored at the server) -> UTF8 (transported through the network) -> UTF16 (string in .NET).
b) If Unicode=true:
UTF16 -> UTF8 -> UTF16. Unfortunately, UTF16 can not be used at the network level.
c) If Unicode=false:
WE8MSWIN1252->WE8MSWIN1252->UTF16.

Posted: Mon 19 Jan 2009 14:38
by Alladin
Thank you very much for the detailed answer.

As a logical conclusion, it is safer to use Unicode. Always. Right?

And there is no obvious performance penalty: transport data should always be converted in Unicode/.NET whether from some single byte codepage or from UTF8.

So Unicode is our choice!

Posted: Mon 19 Jan 2009 16:34
by Shalex
The only disadvantage of using Unicode=true is performance penalty. But it is negligible.