air icon indicating copy to clipboard operation
air copied to clipboard

Fix garbled encoding issue when build fails on non-Latin Windows systems

Open fanyang89 opened this issue 5 months ago • 0 comments

The default encoding in Go is UTF-8. However, when cmd.exe is run on non-Latin Windows systems, it may use an encoding other than UTF-8, which can lead to garbled text.

This patch addresses the issue by running chcp to set the code page to UTF-8 before executing commands.

Reproduce(run on a non-latin Windows):

air init

Then modify the .air.toml:

  bin = "tmp\\main.exe"
  cmd = "go build -o ./tmp/main.exe ."

To(leave tmp_dir alone)

  bin = "bin\\main.exe"
  cmd = "go build -o ./bin/main.exe ."

Before this patch:

image

After:

image

fanyang89 avatar Jan 19 '24 18:01 fanyang89