pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.62k stars 518 forks source link

Same code different result from command line, maybe about encode #1081

Closed robertlzj closed 4 years ago

robertlzj commented 4 years ago
local sOut = io.popen( 'chcp 65001 | dir /T:C "' .. 'G:\\中 文.txt' .. '"', 'r' )
local sData = sOut:read "*a"
sOut:close()
print(sData,'\n',string.find(sData,'中 文.txt',1,true)~=nil)

Result and sData should be:

驱动器 G 中的卷是 RobertL 卷的序列号是 0001-1957

G:\ 的目录

2020/09/14 08:03 0 中 文.txt 1 个文件 0 字节 0 个目录 31,445,549,056 可用字节

true

But, sometimes string.find get false, even the display output is correct. So, the actual output maybe in different encode other (cp936?) than pattern in script the UTF8 (cp65001). And result would be in English.

Volume in drive G is RobertL Volume Serial Number is 0001-1957

Directory of G:\

2020/09/14 08:03 0 中 文.txt 1 File(s) 0 bytes 0 Dir(s) 31,445,549,056 bytes free

true

Seems when result is English, the string match always gets true. Very confuse.

ildar commented 4 years ago

I'm sorry this seems to be unrelated to ZBS.

I suggest you asking at any of Lua IRC or Matrix chats.

pkulchenko commented 4 years ago

I agree, it looks confusing, but I don't think it has anything to do with the IDE, as it only displays the output of those commands and don't "translate" them.