Oracle® Database Globalization Support Guide 10g Release 1 (10.1) Part Number B10749-01 |
|
|
View PDF |
This chapter contains information about OCI programming in a global environment. It includes the following topics:
Many OCI NLS functions accept one of the following handles:
The OCI environment handle is associated with the client NLS environment and initialized with the client NLS environment variables. This environment does not change when ALTER
SESSION
statements are issued to the server. The character set associated with the environment handle is the client character set.
The OCI session handle is associated with the server session environment. Its NLS settings change when the session environment is modified with an ALTER
SESSION
statement. The character set associated with the session handle is the database character set.
Note that the OCI session handle does not have any NLS settings associated with it until the first transaction begins in the session. SELECT
statements do not begin a transaction.
See Also:
Oracle Call Interface Programmer's Guide for detailed information about the OCI NLS functions |
Use the OCIEnvNlsCreate
function to specify client-side database and national character sets when the OCI environment is created.This function allows users to set character set information dynamically in applications, independent of the NLS_LANG
and NLS_NCHAR
initialization parameter settings. In addition, one application can initialize several environment handles for different client environments in the same server environment.
Any Oracle character set ID except AL16UTF16 can be specified through the OCIEnvNlsCreate
function to specify the encoding of metadata, SQL CHAR
data, and SQL NCHAR
data. Use OCI_UTF16ID
in the OCIEnvNlsCreate
function to specify UTF-16 data.
See Also:
Oracle Call Interface Programmer's Guide for more information about the |
An Oracle locale consists of language, territory, and character set definitions. The locale determines conventions such as day and month names, as well as date, time, number, and currency formats. A globalized application complies with a user's locale setting and cultural conventions. For example, when the locale is set to German, users expect to see day and month names in German.
You can use the OCINlsGetInfo()
function to retrieve the following locale information:
Table 10-1 summarizes OCI functions that return locale information.
The OCINlsNameMap
function maps Oracle character set names, language names, and territory names to and from Internet Assigned Numbers Authority (IANA) and International Organization for Standardization (ISO) names.
Two types of data structures are supported for string manipulation:
Native character strings are encoded in native Oracle character sets. Functions that operate on native character strings take the string as a whole unit with the length of the string calculated in bytes. Wide character (wchar
) string functions provide more flexibility in string manipulation. They support character-based and string-based operations with the length of the string calculated in characters.
The wide character datatype is Oracle-specific and should not be confused with the wchar_t
datatype defined by the ANSI/ISO C standard. The Oracle wide character datatype is always 4 bytes in all platforms, while the size of wchar_t
depends on the implementation and the platform. The Oracle wide character datatype normalizes native characters so that they have a fixed width for easy processing. This guarantees no data loss for round-trip conversion between the Oracle wide character format and the native character format.
String manipulation can be classified as followings:
Table 10-2 summarizes the OCI string manipulation functions.
Note: The functions and descriptions in Table 10-2 that refer to multibyte strings apply to native character strings. |
Table 10-3 shows the OCI character classification functions.
Conversion between Oracle character sets and Unicode (16-bit, fixed-width Unicode encoding) is supported. Replacement characters are used if a character has no mapping from Unicode to the Oracle character set. Therefore, conversion back to the original character set is not always possible without data loss.
Table 10-4 summarizes the OCI character set conversion functions.
The user message API provides a simple interface for cartridge developers to retrieve their own messages as well as Oracle messages.
Table 10-5 summarizes the OCI messaging functions.
The lmsgen
utility converts text-based message files (.msg
) into binary format (.msb
) so that Oracle messages and OCI messages provided by the user can be returned to OCI functions in the desired language.
LMSGEN text_file product facility [language]
text_file
is a message text file.product
is the name of the product.facility
is the name of the facility.language
is the optional message language corresponding to the language specified in the NLS_LANG
parameter. The language parameter is required if the message file is not tagged properly with language.
Text message files must follow these guidelines:
/
and //
are treated as internal comments and are ignored.# CHARACTER_SET_NAME= Japanese_Japan.JA16EUC
message_number, warning_level, message_text
The following is an example of an Oracle message text file:
/ Copyright (c) 2001 by the Oracle Corporation. All rights reserved. / This is a test us7ascii message file # CHARACTER_SET_NAME= american_america.us7ascii / 00000, 00000, "Export terminated unsuccessfully\n" 00003, 00000, "no storage definition found for segment(%lu, %lu)"
The following table contains sample values for the lmsgen
parameters:
Parameter | Value |
---|---|
|
|
|
|
|
|
|
|
The text message file is found in the following location:
$HOME/myApp/mesg/impus.msg
One of the lines in the text message file is:
00128,2, "Duplicate entry %s found in %s"
The lmsgen
utility converts the text message file (impus.msg
) into binary format, resulting in a file called impus.msb
:
% lmsgen impus.msg $HOME/myApplication imp AMERICAN
The following output results:
Generating message file impus.msg --> /home/scott/myApplication/mesg/impus.msb NLS Binary Message File Generation Utility: Version 10.1.0.0.0 -Production Copyright (c) Oracle Corporation 1979, 2003. All rights reserved. CORE 10.1.0.0.0 Production