do not abort on incorrect filenames in filesystem
[booh] / lib / booh / booh-lib.rb
index 8c246aa841f3ec2c6a0835cb85a1858a5a06611f..54cc077f1086873176373905044dd8f5cc2f6eeb 100644 (file)
@@ -54,7 +54,11 @@ module Booh
     $convert_enhance = '-contrast -enhance -normalize'
 
     def utf8(string)
-        return Iconv::iconv("UTF-8", $CURRENT_CHARSET, string).to_s
+        begin
+            return Iconv::iconv("UTF-8", $CURRENT_CHARSET, string).to_s
+        rescue
+            return "???"
+        end
     end
 
     def utf8cut(string, maxlen)
@@ -62,6 +66,8 @@ module Booh
             return Iconv::iconv("UTF-8", $CURRENT_CHARSET, string[0..maxlen-1]).to_s
         rescue Iconv::InvalidCharacter
             return utf8cut(string, maxlen-1)
+        rescue
+            return "???"
         end
     end