> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# char_length

> 返回字符串的字符数，支持多字节字符和 UTF-8 编码。

返回字符串的长度。
对于多字节字符，返回 **字符** 数，目前仅支持 UTF-8 编码，该函数还有一个别名 `character_length`。

## 语法

```Haskell theme={null}
char_length(str)
```

## 参数说明

`str`: 支持的数据类型为 VARCHAR。

## 返回值说明

返回值的数据类型为 INT。

## 示例

```Plain Text theme={null}
MySQL > select char_length("abc");
+--------------------+
| char_length('abc') |
+--------------------+
|                  3 |
+--------------------+

MySQL > select char_length("中国");
+----------------------+
| char_length('中国')  |
+----------------------+
|                    2 |
+----------------------+
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.