1

I have directories with non-ascii characters, and when I diff them, the diff output shows escape sequences instead of the utf8 characters:

robert@saaz:~$ mkdir foo föö
robert@saaz:~$ echo 1 > foo/bar
robert@saaz:~$ echo 2 > föö/bar

robert@saaz:~$ diff -r f??
diff -r foo/bar "f\303\266\303\266/bar"
1c1
< 1
---
> 2

Instead of f\303\266\303\266/bar in the first line of the diff output, I expected föö.

I'm on Ubuntu 20.04 with diff 3.7:

robert@saaz:~$ diff --version
diff (GNU diffutils) 3.7
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Paul Eggert, Mike Haertel, David Hayes,
Richard Stallman, and Len Tower.

When I use ls (even with clearing LS_OPTIONS) to look at the directories, they are shown with utf8 characters as expected:

robert@saaz:~$ LS_OPTIONS=x ls -ld f??
drwxrwxr-x 2 robert robert 4.0K 2020-08-06 17:38 foo
drwxrwxr-x 2 robert robert 4.0K 2020-08-06 17:39 föö

My locale is all utf8:

robert@saaz:~$ locale
LANG=en_US.UTF-8
LANGUAGE=en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

How do I get diff to also show non-ascii characters?

1 Answer 1

0

This is a problem in the GNU diff implementation.

You could use the UNIX diff implementation instead of gdiff.

A portable version of the UNIX diff command is part of the schilytools, Check:

/usr/bin/diff -r f??
diff -r foo/a "f\366\366/a"
1c1
< a
---
> b

vs:

/opt/schily/ccs/bin/diff -r f??
diff -r foo/a föö/a
1c1
< a
---
> b

/opt/schily/ccs/bin/diff -version
diff schily-SCCS version 5.09 2020/07/14 (x86_64-unknown-linux-gnu)

The source download is at: http://sourceforge.net/projects/schilytools/files/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .