The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Changing filename encodings in a tarball, and a small refactoring tale

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eigen Class

Posts: 358
Nickname: eigenclass
Registered: Oct, 2005

Eigenclass is a hardcore Ruby blog.
Changing filename encodings in a tarball, and a small refactoring tale Posted: May 1, 2006 6:30 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eigen Class.
Original Post: Changing filename encodings in a tarball, and a small refactoring tale
Feed Title: Eigenclass
Feed URL: http://feeds.feedburner.com/eigenclass
Feed Description: Ruby stuff --- trying to stay away from triviality.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eigen Class
Latest Posts From Eigenclass

Advertisement

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:


Read more...

Read: Changing filename encodings in a tarball, and a small refactoring tale

Topic: Commands and Colors: Ancients Previous Topic   Next Topic Topic: #caboose

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use