I had to transfer a few GB from a dying machine to an HFS+ partition; since I
had the tarballs, it should have been a piece of cake, but:
$ tar xvf bleh.tar
programaci\363n/
tar: programaci\363n: Cannot mkdir: Invalid argument
tar: Error exit delayed from previous errors
The tarballs contain some ISO-8859_1-encoded filenames which are obviously not
valid UTF8 streams*1.
So I wrote a script to change the filename encodings in a tarball to UTF8 on the fly.
As happens often as of late*2, I had some
2-year-old code of mine lying around that solved most of the problem.
Here's the code (recode-tarball-utf8.rb)
in case you also run into troubles with non-UTF8 filenames in your tarballs.
A small refactoring tale
De/encoding a tar header is quite repetitive by itself; a POSIX ("ustar") header
looks like this: