1
mirror of https://github.com/rclone/rclone synced 2024-11-18 18:46:07 +01:00

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
This commit is contained in:
Nick Craig-Wood 2018-09-14 12:01:52 +01:00
parent bc8f0208aa
commit 8d72ef8d1e
2 changed files with 13 additions and 0 deletions

View File

@ -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)

View File

@ -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