samizdat-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

avoid non-ascii in ruby code files ? proposed patch to template.rb


From: boud
Subject: avoid non-ascii in ruby code files ? proposed patch to template.rb
Date: Sat, 10 Feb 2007 01:39:25 +0100 (CET)

hi samizdat-devel,

While samizdat is throughout very much UTF-8'ised, chances are that
if someone is copying code and/or making minor changes, s/he might
accidentally do something that converts UTF-8 to another character
set (e.g. reads it in in one charset and saves it in another).

In fact, i (presumably) made this error and got three strange characters
instead of the "..." character (ellipsis) in the html_short field of a couple of articles. :P The problem is with the ellipsis in template.rb

Since i didn't succeed in getting
  MessageContent.html_all_regenerate
to work from the command line (more info later if someone wants to help),
i had to hack a bit to fix the articles.

While the UTF-8 version looks nice in an editor with the editor and
terminal locales done properly, IMHO we should write it more safely.
Again, it's the sort of small thing which could discourage many people - especially as it shows up on the front page.


i propose:

--- lib/samizdat/engine/template.rb     2007-01-20 12:59:03.000000000 +0100
+++ /usr/lib/ruby/1.8/samizdat/engine/template.rb       2007-02-09 
23:26:15.292208856 +0100
@@ -141,7 +141,8 @@
   def Template.limit_string(string, limit=config['limit']['title'])
     $KCODE = 'utf8'
     if string.jsize > limit
-      string.each_char[0, limit - 1].join + '…'
+#      string.each_char[0, limit - 1].join + '…'
+      string.each_char[0, limit - 1].join + "\xe2\x80\xa6"
     else
       string
     end


solidarity
boud

reply via email to

[Prev in Thread] Current Thread [Next in Thread]