Purpose
TO_SINGLE_BYTE() converts all multi-byte characters into the corresponding single-byte characters. This function is valid only when your database character set contains both single-byte and multi-byte characters.
Syntax
TO_SINGLE_BYTE(char)
Parameters
char can be CHAR, VARCHAR2, NCHAR, or NVARCHAR2. If a multi-byte character in char does not have a single-byte equivalent, the multi-byte character is displayed in the output character string.
Return type
The return type is the same as the data type of char.
Examples
The following example converts the multi-byte B in UTF8 to the corresponding single-byte B in ASCII.
obclient> SELECT TO_SINGLE_BYTE(CHR(15711394)) FROM DUAL; +-------------------------------+ | TO_SINGLE_BYTE(CHR(15711394)) | +-------------------------------+ | B | +-------------------------------+ 1 row in setThe following example converts full-width characters in a string into half-width characters.
obclient> SELECT TO_SINGLE_BYTE('Hello World') AS text FROM DUAL; +--------------+ | TEXT | +--------------+ | Hello World | +--------------+ 1 row in set