hopefully fixing the rest of potential aborts, thx to a suggestion from fif
[booh] / lib / booh / booh-lib.rb
index 1dc435ef5cfc001fdb1bea58cd99a42a0663d6e8..e1a7e6fc1750f7570b30b75c39f736b52d1f234d 100644 (file)
@@ -59,6 +59,14 @@ module Booh
         return Iconv::iconv($CURRENT_CHARSET, "UTF-8", string).to_s
     end
 
+    def from_utf8_safe(string)
+        begin
+            return Iconv::iconv($CURRENT_CHARSET, "UTF-8", string).to_s
+        rescue Iconv::IllegalSequence
+            return nil
+        end
+    end
+
     def make_dest_filename_old(orig_filename)
         #- we remove non alphanumeric characters but need to do that
         #- cleverly to not end up with two similar dest filenames. we won't