On this page本页内容
$strLenCP
¶New in version 3.4.版本3.4中的新功能。
Returns the number of UTF-8 code points in the specified string.
$strLenCP
has the following operator expression syntax:
The argument can be any valid expression as long as it resolves to an string. For more information on expressions, see Expressions.有关表达式的详细信息,请参阅表达式。
If the argument resolves to a value of null
or refers to a missing field, $strLenCP
returns an error.
{ $strLenCP: "abcde" } |
5 |
{ $strLenCP: "Hello World!" } |
12 |
{ $strLenCP: "cafeteria" } |
9 |
{ $strLenCP: "cafétéria" } |
9 |
{ $strLenCP: "" } |
0 |
{ $strLenCP: "$€λA" } |
4 |
{ $strLenCP: "寿司" } |
2 |
The $strLenCP
operator counts the number of code points in the specified string. This behavior differs from the $strLenBytes
operator which counts the number of bytes in the string, where each character uses between one and four bytes.