Skip to content
Advertisement

Count the length of Chinese character in sql

I have a string that includes Chinese characters in it. I want to calculate the length of the string but I want to count 1 Chinese character equals to 3 characters.

Here are the strings and how I am counting length of strings.

The first string returns length = 80 while the second string returns length = 41. But what I want is it should return length of second string = 47 as there are 3 Chinese characters in the string and 1 should be equal to 3 so the length should be 47.

Is it possible ?

Advertisement

Answer

If you want to length in Unicode characters you should use LENGTHC function.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement