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