NLS_CHARACTERSET is AL23UTF8 in my Oracle database. I have a problem when using the RPAD function:
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 Connected as apps@UATSED SQL> SQL> SELECT 'η²ιͺ¨ζ' ORACLE, LENGTHB('η²ιͺ¨ζ') ORACLE_LENGTH, 2 RPAD('η²ιͺ¨ζ', 10, '$') ORA_RPAD, LENGTHB(RPAD('η²ιͺ¨ζ', 10, '$')) ORA_RPAD_LENGTH 3 FROM dual 4 ; ORACLE ORACLE_LENGTH ORA_RPAD ORA_RPAD_LENGTH
We know that the Chinese character takes 3 bytes in the AL32UTF8 encoding method. Therefore, in my example, the lengthb function returns the correct result. But we use the RPAD function to place more spaces with $, 2 Chinese bytes are required for one Chinese character, not 3 bytes. Therefore, when I type 10 bytes in total, it filled in 4-digit characters for me.
My question is: why does the RPAD function not match the lengthb method?
source share