码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-03-10 16:45:24      阅读:303      评论:0      收藏:0      [点我收藏+]

标签:

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

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的下标要估计好了。

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

标签:

原文地址:http://www.cnblogs.com/asheCoder/p/4326156.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!