oracle-databaseutf-8nls-lang

Set the NLS_LANG


We have a database with AL32UTF8 as character set. Our application supports EN, FR, DE and JP languages. In Each release we insert new labels into the table managing the translations. what the NLS_LANG of the client should be, to ensure that french special characters and Japanese are inserted correctly into the database ?

Please note that each client has his own database. Is there any automatic way to ensure that the used NLS_LANG is the good one ? I have already read this article but I do not know how can I achieve this. Thanks, Bilel


Solution

  • If you have to deal with Japanese and European languages then AL32UTF8 (i.e. UTF-8) is actually the only useful option.

    The linked article is has some flaws, for example "...on a Windows operating system, then you should not set AL32UTF8 as the client character set in the NLS_LANG parameter because there are no UTF-8 WIN32 clients." That's wrong, nowadays almost every windows client is UTF-8 capable. Every text editor you use to write *sql files supports UTF-8, when you use plain sql*Plus then a simple chcp 65001 command makes it UTF-8. Only the ancient and deprecated drivers from Microsoft do not support Unicode.

    Please recognize, when you set for example NLS_LANG=.AL32UTF8 value then you tell the Oracle database: "My client application uses characters set AL32UTF8 (a.k.a. UTF-8)" - no more, no less.

    It does not automatically mean that your client application is really using UTF-8, many times you have to specify it explicitly in some settings (however there are applications and drivers which automatically follow the NLS_LANG value).

    See OdbcConnection returning Chinese Characters as "?" for more information.