From 8d72ef8d1e9bf21ea13a78ad00ce74f63fc1c5ab Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 14 Sep 2018 12:01:52 +0100 Subject: [PATCH] cmd: Don't print non-ASCII characters with --progress on windows - fixes #2501 This bug causes lots of strange behaviour with non-ASCII characters and --progress https://github.com/Azure/go-ansiterm/issues/26 --- cmd/progress_windows.go | 9 +++++++++ docs/content/docs.md | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/cmd/progress_windows.go b/cmd/progress_windows.go index aa7493b8f..e0ee6ffaf 100644 --- a/cmd/progress_windows.go +++ b/cmd/progress_windows.go @@ -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) diff --git a/docs/content/docs.md b/docs/content/docs.md index 4acb790d4..f84e57fbd 100644 --- a/docs/content/docs.md +++ b/docs/content/docs.md @@ -681,6 +681,10 @@ with the `--stats` flag. This can be used with the `--stats-one-line` flag for a simpler display. +Note: On Windows until[this bug](https://github.com/Azure/go-ansiterm/issues/26) +is fixed all non-ASCII characters will be replaced with `.` when +`--progress` is in use. + ### -q, --quiet ### Normally rclone outputs stats and a completion message. If you set