Skip to content

Commit 89973b3

Browse files
authored
Merge pull request #549 from Naahuel/master
Add change encoding to bat file for dtutils/system.lua windows_command Thanks.
2 parents deca366 + 1e33ea4 commit 89973b3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/dtutils/system.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ function dtutils_system.windows_command(command)
8787
if file then
8888
dt.print_log("opened file")
8989
command = string.gsub(command, "%%", "%%%%") -- escape % from windows shell
90-
file:write(command)
90+
file:write("@echo off\n")
91+
file:write('for /f "tokens=2 delims=:." %%x in (\'chcp\') do set cp=%%x\n')
92+
file:write("chcp 65001>nul\n") -- change the encoding of the terminal to handle non-english characters in path
93+
file:write("\n")
94+
file:write(command .. "\n")
95+
file:write("\n")
96+
file:write("chcp %%cp%%>nul\n")
9197
file:close()
9298

9399
result = dt.control.execute(fname)

0 commit comments

Comments
 (0)