Skip to main content

CHAR_LENGTH

Description

Calculates the length of a string. For multi-byte characters, returns the number of characters.

Currently only supports utf8 encoding

Alias

  • CHARACTER_LENGTH

Syntax

CHAR_LENGTH ( <str> )

Parameters

ParameterDescription
<str>The string to calculate the length of

Return value

The length of the string .

Example

select CHAR_LENGTH("abc"),CHAR_LENGTH("中国")
+-------------------------+----------------------------+
| character_length('abc') | character_length('中国') |
+-------------------------+----------------------------+
| 3 | 2 |
+-------------------------+----------------------------+