Index: bin/booh-backend
===================================================================
RCS file: /opt/cvs/booh/bin/booh-backend,v
retrieving revision 1.64
diff -u -r1.64 booh-backend
--- bin/booh-backend	12 Nov 2005 23:54:44 -0000	1.64
+++ bin/booh-backend	16 Nov 2005 21:36:44 -0000
@@ -660,7 +660,7 @@
                 else
                     type = entry2type(file)
                     if type && !xmldir.elements["#{type}[@filename='#{utf8(file)}']"]
-                        xmldir.add_element type, { "filename" => utf8(file), "caption" => $empty_comments ? '' : utf8(file.sub(/\.[^\.]+$/, '')[0..17]) }
+                        xmldir.add_element type, { "filename" => utf8(file), "caption" => $empty_comments ? '' : utf8cut(file.sub(/\.[^\.]+$/, ''), 18) }
                     end
                 end
             end
Index: lib/booh/booh-lib.rb
===================================================================
RCS file: /opt/cvs/booh/lib/booh/booh-lib.rb,v
retrieving revision 1.53
diff -u -r1.53 booh-lib.rb
--- lib/booh/booh-lib.rb	12 Nov 2005 23:54:44 -0000	1.53
+++ lib/booh/booh-lib.rb	16 Nov 2005 21:32:58 -0000
@@ -39,6 +39,14 @@
         return Iconv::iconv("UTF-8", $CURRENT_CHARSET, string).to_s
     end
 
+    def utf8cut(string, maxlen)
+        begin
+            return Iconv::iconv("UTF-8", $CURRENT_CHARSET, string[0..maxlen-1]).to_s
+        rescue Iconv::InvalidCharacter
+            return utf8cut(string, maxlen-1)
+        end
+    end
+
     def sizename(key)
         #- fake for gettext to find these; if themes need more sizes, english name for them should be added here
         sizenames = { 'small' => utf8(_("small")), 'medium' => utf8(_("medium")), 'large' => utf8(_("large")),

