ret
end
- ## one of the few things i miss from perl
- def ucfirst
- self[0 .. 0].upcase + self[1 .. -1]
- end
-
## a very complicated regex found on teh internets to split on
## commas, unless they occurr within double quotes.
def split_on_commas
def normalize_whitespace
gsub(/\t/, " ").gsub(/\r/, "")
end
+
+ ## takes a space-separated list of words, and returns an array of symbols.
+ ## typically used in Sup for translating Ferret's representation of a list
+ ## of labels (a string) to an array of label symbols.
+ def symbolistize; split.map { |x| x.intern } end
end
class Numeric
@m.synchronize { !@over && @over = true }
end
end
+
+class Iconv
+ def self.easy_decode target, charset, text
+ return text if charset =~ /^(x-unknown|unknown[-_ ]?8bit|ascii[-_ ]?7[-_ ]?bit)$/i
+ charset = case charset
+ when /UTF[-_ ]?8/i: "utf-8"
+ when /(iso[-_ ])?latin[-_ ]?1$/i: "ISO-8859-1"
+ when /iso[-_ ]?8859[-_ ]?15/i: 'ISO-8859-15'
+ when /unicode[-_ ]1[-_ ]1[-_ ]utf[-_]7/i: "utf-7"
+ else charset
+ end
+
+ # Convert:
+ #
+ # Remember - Iconv.open(to, from)!
+ Iconv.iconv(target + "//IGNORE", charset, text + " ").join[0 .. -2]
+ end
+end