How oracle determine whether the string contains Chinese? Super simple!

1. scenario demonstrates

  How quickly determine whether the specified string contains Chinese do? 

2. Solution

  Analyzing the results by a length () and lengthb () function ratio. 

  lengthb (string) calculating the byte length occupied by the string: Returns the length of the string of bytes, in bytes;

  length (string) is calculated character string length occupied: Returns the character string length in characters.

  In English, an English character only one byte;

  In Chinese, a Chinese character for at least two bytes, a byte character sets how many characters make up the database with the related Oracle database, UTF8, the length is three.

  Therefore, by determining whether the return value of the function equal to two, can determine whether the string contains Chinese.

  length('string')=lengthb('string')

SELECT DECODE (LENGTH ( 'string'), LENGTHB ( 'string'), 'does not comprise', 'comprising') contains Chinese FROM DUAL

 

Written in the last

  Which big brother If it is found there is leakage of the carelessness of the article or need to add more content, welcome message! ! !

 related suggestion:

 

Guess you like

Origin www.cnblogs.com/Marydon20170307/p/10978399.html