2 Day Developer > Working in a Global Environ... > SQL and PL/SQL Programming ... > Unicode String Literals
Unicode String Literals |
Previous |
Next |
You can input Unicode string literals in SQL and PL/SQL as follows:
Put the letter N
before a string literal that is enclosed with single quotation marks. This explicitly indicates that the following string literal is an NCHAR
string literal. For example, N'résumé'
is an NCHAR
string literal. See "NCHAR Literal Replacement" for limitations of this method.
Use the NCHR(
n
)
SQL function. The NCHR(
n
)
SQL function returns a unit of character code in the national character set, which is AL16UTF16 or UTF8. The result of concatenating several NCHR(
n
)
functions is NVARCHAR2
data. In this way, you can bypass the client and server character set conversions and create an NVARCHAR2
string directly. For example, NCHR(32)
represents a blank character.
Because NCHR(
n
)
is associated with the national character set, portability of the resulting value is limited to applications that use the same national character set. If this is a concern, then use the UNISTR
function to remove portability limitations.
Use the UNISTR
('string'
) SQL function. The UNISTR
('string'
) function converts a string to the national character set. To ensure portability and to preserve data, include only ASCII characters and Unicode encoding in the following form: \xxxx
, where xxxx
is the hexadecimal value of a character code value in UTF-16 encoding format. For example, UNISTR('G\0061ry')
represents 'Gary'
. The ASCII characters are converted to the database character set and then to the national character set. The Unicode encoding is converted directly to the national character set.
The last two methods can be used to encode any Unicode string literals.