函数:string.len 获取字符串字节数

函数名称:获取字符串字节数

函数功能:获取字符串字节数

函数方法

num = string.len(str)

参数 类型 必填 说明
str string 需要计算的字符串
返回值 类型 说明
num number/nil 字符串字节数

函数用例

str="JUST DO IT"
num = string.len(str)
dialog("字符串字节数:"..num)

注意事项

  • 功能与 # 相同,获取的是字节长度,非字符长度,

  • 日常使用的 99% 1 个汉字是 3 个字节,生僻字或 emoji 是 4 个字节。

  • 1 个数字/字母/符号= 1个字节。

Copyright 北京帮你玩科技有限公司 2024 all right reserved,powered by Gitbook该文章修订时间: 2025-12-03 17:46:16

results matching ""

    No results matching ""