Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.0 » SQL Anywhere Server - SQL Reference » Using SQL » SQL functions » Alphabetical list of functions


UNISTR function [String]

Converts a string containing characters and Unicode escape sequences to an NCHAR string.

UNISTR( string-expression )
  • string-expression   The string to be converted.


The UNISTR function allows the use of Unicode characters that cannot be represented in the CHAR character set used by the SQL statement. For example, in an English environment, the UNISTR function could be used to include Chinese characters.

The UNISTR function offers similar functionality to the N'' constant, however the UNISTR function allows Unicode characters and characters from the CHAR character set, whereas the N'' constant only allows characters from the CHAR character set.

The string-expression contains characters and Unicode escape sequences. The Unicode escape sequences are of the form \uXXXX or \uXXXXXX, where each X is a hexadecimal digit. The UNISTR function converts each character and each Unicode escape sequence to the corresponding Unicode character.

If a 6-digit Unicode escape sequence is used, its value must not exceed 10FFFF, the largest Unicode code point. A sequence such as \u234567 is not a 6-digit Unicode escape sequence. It is the 4-digit sequence \u2345 followed by the characters 6 and 7.

If two adjacent Unicode escape sequences form a UTF-16 surrogate pair, they are combined into one Unicode character in the output.

See also
Standards and compatibility
  • SQL/2003   Vendor extension.


The following example returns the string Hello.

SELECT UNISTR( 'Hel\u006c\u006F' );

The following example combines the UTF-16 surrogate pair D800-DF02 into the Unicode code point 10302.

SELECT UNISTR( '\uD800\uDF02' );

The example is equivalent to the previous one.

SELECT UNISTR( '\u010302' );