[Decode error - output not utf-8] lua 使用string.sub

对已知中文字符串进行分割,以“(”和“)”来截取字符串;

str1="白雪皑皑雪橇行,胡子老人把人惊(落花无声)";
print(str1);
num1 = string.find(str1,'(')
num2 = string.find(str1,')')
print(num1,":",num2);
print(string.sub(str1,num1,num2))

运行输出;

[Decode error - output not utf-8]

在网上搜有关 not utf-8的很多;但仔细看看好像是分割的字符串不是整个的汉字;

因为 ,一个汉字字符占两个字节,所以是由于sub的下标要估计好了。