import console;
// arrdio默认编码为utf-8
// 字符长度 7 占用内存 15
var str1 = "中国測試cjk"
var len1 = string.len(str1)
console.log("字符长度:", len1)
var len2 = #str1
console.log("占用内存:", len2)
// 测试:遍历每字符
var result1 = ""
for(i = 1; string.len(str1); 1) {
result1 = ((string.slice(str1, i, i, true)) " ")
}
console.log(result1)
// 测试:遍历每字节
// #str 取占用内存
// str[i] 取第i字节的ascii码
var result2 = ""
for(i = 1; len2; 1) {
result2 = (string.format("\0xX", str1[i]))
}
console.log(result2)