String.char_code
String.char_code
功能
读取指定字符位置的 Unicode 码点。
语法
string.char_code(index)
参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| index | Int | 否 | 0 | 字符下标,负数会按 0 处理。 |
返回值
| 类型 | 说明 |
|---|---|
| Int/Null | 下标存在时返回码点整数;越界时返回 Null。 |
示例
text = 'A' result = text.char_code(0) // 输出:65 echo(result)
注意事项
- ASCII 字符返回对应字节值;非 ASCII 字符返回 Unicode 码点。