Skip to content

Commit

Permalink
cmd: Don't print non-ASCII characters with --progress on windows - fixes
Browse files Browse the repository at this point in the history
 #2501

This bug causes lots of strange behaviour with non-ASCII characters and --progress

Azure/go-ansiterm#26
  • Loading branch information
ncw committed Oct 10, 2018
1 parent 364fca5 commit f6c174e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/progress_windows.go
Expand Up @@ -21,6 +21,15 @@ func writeToTerminal(b []byte) {
winEventHandler := winterm.CreateWinEventHandler(os.Stdout.Fd(), os.Stdout)
ansiParser = ansiterm.CreateParser("Ground", winEventHandler)
})
// Remove all non-ASCII characters until this is fixed
// https://github.com/Azure/go-ansiterm/issues/26
r := []rune(string(b))
for i := range r {
if r[i] >= 127 {
r[i] = '.'
}
}
b = []byte(string(r))
_, err := ansiParser.Parse(b)
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "\n*** Error from ANSI parser: %v\n", err)
Expand Down

0 comments on commit f6c174e

Please sign in to comment.