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