how to display spaces and tabs using unix and & ldquo; cat & rdquo; order


I'm trying to figure out how to display the contents of a file through unix where the spaces and tabs are marked somehow. I know how to display the files with tabs (aka cat -T filename) but I've been trying to figure out how to show the spaces as well. cat -A filename doesn't work for me, and only replaces tabs with ^I and places $ at the end of the line. How can I utilize cat to print out a file with all tabs and spaces clearly marked?

There's a standard unix tool for character substitution. In this example, I'm replacing spaces for * and tabs for &:

$ cat tmp
space tab   space   tab end
tab space   tab space end
$ cat tmp | tr " " "*" | tr "\t" "&"