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 fu nctions 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. T
his environment does not change when ALTER SESSION statements are issued to the server. The character set a
ssociated with the environment handle is the client character set.
The OCI session handle i
s associated with the server session environment. Its NLS settings change when the session environment is modified with an ALTE
R 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.
Oracle Call Interface Programmer's Guide for detailed information about the OCI NLS functions |
An Oracle locale consists of language, territory, and character set definiti ons. 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 exp ect to see day and month names in German.
You can use the OCINlsGetInfo() func
tion to retrieve the following locale information:
Table 10-1 summarizes OCI functions that return locale information.
| Function th> | |
|---|---|
|
OCINlsGetInfo() |
Returns locale informat ion. See preceding text. |
|
OCINlsCharSetNameTold() |
Returns the Oracle character set I D for the specified Oracle character set name |
|
OCINlsCharSetIdToName() |
Returns the O racle character set name from the specified character set ID |
|
OCINlsNumericInfoGet() |
Returns specified numeric information such as maximum character size |
|
OCINlsEnvironmentVariableGet() |
a>
Returns the character set ID from |
The OCINlsNameMap function maps Oracl
e character set names, language names, and territory names to and from Internet Assigned Numbers Authority (IANA) and International O
rganization 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 lo
ss 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 betw een Oracle character sets and Unicode (16-bit, fixed-width Unicode encoding) is supported. Replacement characters are used if a chara cter 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 th e 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 messa ges.
Table 10-5 summarizes th e OCI messaging functions.
The lmsgen utility converts text-based message files (.msg) into binary format (.msb) so tha
t Oracle messages and OCI messages provided by the user can be returned to OCI functions in the desired language.
LMSGENtext_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.message_number em>, warning_level, message_text
The following is an example of an Oracle message te xt 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 de finition found for segment(%lu, %lu)"
The following table contains sample values for the lmsgen parameters:
| |
Value |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
The text message file is found in the fo llowing location:
$HOME/myApp/mesg/impus.msg
One of the lines in the text message file is:
00128,2, "Duplicate ent ry %s found in %s"
The lmsgen utility converts the t
ext 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 U tility: Version 10.1.0.0.0 -Production Copyright (c) Oracle Corporation 1979, 2003. All rights reserved. CORE 10.1.0.0.0 Production