char_length

Description

Syntax

INT char_length(VARCHAR str)

Returns the length of the string, and the number of characters returned for multi-byte characters. For example, five two-byte width words return a length of 5, only utf8 encoding is support at the current version. character_length is the alias for this function.

example

1. mysql> select char_length("abc");
2. +--------------------+
3. | char_length('abc') |
4. +--------------------+
5. |                  3 |
6. +--------------------+

8. mysql> select char_length("中国");
9. +------------------- ---+
10. | char_length('中国')   |
11. +-----------------------+
12. |                     2 |
13. +-----------------------+

keywords

1. CHAR_LENGTH, CHARACTER_LENGTH