Skip to content

Add change encoding to bat file for dtutils/system.lua windows_command #549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/dtutils/system.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ function dtutils_system.windows_command(command)
if file then
dt.print_log("opened file")
command = string.gsub(command, "%%", "%%%%") -- escape % from windows shell
file:write(command)
file:write("@echo off\n")
file:write('for /f "tokens=2 delims=:." %%x in (\'chcp\') do set cp=%%x\n')
file:write("chcp 65001>nul\n") -- change the encoding of the terminal to handle non-english characters in path
file:write("\n")
file:write(command .. "\n")
file:write("\n")
file:write("chcp %%cp%%>nul\n")
file:close()

result = dt.control.execute(fname)
Expand Down