do not abort on incorrect filenames in filesystem
authorGuillaume Cottenceau <gcottenc@gmail.com>
Tue, 15 Sep 2009 13:31:17 +0000 (15:31 +0200)
committerGuillaume Cottenceau <gcottenc@gmail.com>
Tue, 15 Sep 2009 13:31:17 +0000 (15:31 +0200)
lib/booh/booh-lib.rb

index 8c246aa..54cc077 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