Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

cmd: Don't print non-ASCII characters with --progress on windows - fixes #2501

Nick Craig-Wood8d72ef8d1e9b
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