From: Lloyd Zusman Date: 2004-08-29T11:36:48+09:00 Subject: Trapping errors within unpack? I'm trying to do a simple conversion between UTF-8 and 8-bit ascii. The key part of my program goes like this: ARGF.each { |line| puts line.unpack('U*').pack('c*') } This works fine unless the input contains an invalid UTF-8 character (which sometimes occurs). In that case, the 'unpack' method terminates at the offending character, and no more translation takes place. What I'd like to do is trap errors like that and put some sort of special character in the output (such as '?') for each invalid UTF-8 character that is encountered, and then continue with the rest of the input. However, I don't know how to do that within 'unpack'. Can anyone suggest a solution? Thanks in advance. -- Lloyd Zusman ljz@asfast.com God bless you.