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

时间: 2024-08-04 17:27:51

[Decode error - output not utf-8] lua 使用string.sub的相关文章

sublime 出现 [Decode error - output not utf-8]

出现以下的错误: Sublime Text 2/3: [Decode error - output not utf-8] 原因: 是因为,sublime 的Java 插件中没有明确 编码格式, 解决方案: 找到你的Packages->java.sublime-package 用 winrar 打开找到 JavaC.sublime-build 在倒数第二行添加 ,"encoding":"cp1252" sublime 出现 [Decode error - out

Sublime Text 2报“Decode error - output not utf-8”错误的解决办法

[Decode error - output not utf-8] [Decode error - output not utf-8] 应该怎么办? 这是因为python配置的编译环境的编码不正确,因为默认的Sublime Text 2的编码是UTF-8. 很简单,解决办法如下: [解决办法]修改Python.sublime-build配置文件,添加如下行: "encoding":"cp936" (注意在上一行结束加逗号)(如图所示)

Sublime text 2/3 [Decode error - output not utf-8] 完美解决方法

分类: 其他2014-05-12 09:52 8063人阅读 评论(9) 收藏 举报 sublime text有时运行会输出以下错误信息: [Decode error - output not utf-8]或者[Decode error - output not gbk] 错误信息意思就是脚本输出的信息不是某种指定编码. 指定的编码一般在XX.sublime-build里,比如ruby.sublime-build的内容为: [python] view plaincopy { "shell_cmd

python sublime3 [Decode error - output not utf-8] 中文显示问题

一般来说,这个是编码问题 祭出大杀器,就能解决问题 # coding: utf-8 import sys reload(sys) sys.setdefaultencoding("utf-8") print '你好' >>>你好 不过今天说的是另一种问题 在sublime里面运行是 [Decode error - output not utf-8] cmd下运行就没问题 代码如下 # coding: utf-8 import sys reload(sys) sys.se

Sublime Text [Decode error - output not utf-8]

改Sublime Text的python build的设置.将其编码设置为cp936. 打开Python.sublime-build文件,并添加”encoding”:”cp936″这一行,保存即可 Sublime Text 3 :SublimeText3/Packages/Python.sublime-package 提醒: Python.sublime-package 其实为压缩包,加上后缀zip 然后解压就能找到Python.sublime-build 改好后,重新打包替换即可

用sublime Text2 运行python报错问题 Decode error - output not utf-8_ 解决办法

sublime 执行print带有中文时出错Decode error - output not utf-8

解决: 打开安装目录D:\developTool\Sublime Text 3\Packages 找到Python.sublime-package,用压缩工具打开 找到Python.sublime-build,并打开 并添加"encoding":"cp936"这一行,保存即可 原文地址:https://www.cnblogs.com/bzdmz/p/10329881.html

Data Flow的Error Output

一,在Data Flow Task中,对于Error Row的处理通过Error Output Tab配置的. 1,操作失败的类型:Error(Conversion) 和 Truncation. 2,错误处理方式:Fail Component,Ignore Failure 和 Redirect Row 3,Error Output增加两个跟Error相关的Column:ErrorCode 和 ErrorColumn,这两个Column的数据类型是DT_4 二,错误处理方式 Fail Compon

Lua的string和string库总结

Lua有7种数据类型,分别是nil.boolean.number.string.table.function.userdata.这里我总结一下Lua的string类型和string库,复习一下,以便加深记忆. 个人认为string是Lua编程使用数据结构的时候,重要性仅次于table的类型.十分重要! 一.string基础. Lua并没有字符类型,Lua的string类型表示字符序列.所以,长度为1的string就表示了单个字符.Lua的字符类型有这些特征: 1.string字符序列中的字符采用