commit 82f55a62a85f5757a1bfe090088ac8a61e2432fc
parent 977cbcedbbcbd4e1c1ff2768369f25b50c04d094
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Mon, 15 Jun 2009 08:01:47 -0700
Merge branch 'master' into next
Diffstat:
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -244,7 +244,7 @@ end
Redwood::log "using character set encoding #{$encoding.inspect}"
else
Redwood::log "warning: can't find character set by using locale, defaulting to utf-8"
- $encoding = "utf-8"
+ $encoding = "UTF-8"
end
## now everything else (which can feel free to call Redwood::log at load time)
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
@@ -172,7 +172,15 @@ class Object
end
class String
- def display_length; scan(/./u).size end
+ ## nasty multibyte hack for ruby 1.8. if it's utf-8, split into chars using
+ ## the utf8 regex and count those. otherwise, use the byte length.
+ def display_length
+ if $encoding == "UTF-8"
+ scan(/./u).size
+ else
+ size
+ end
+ end
def camel_to_hyphy
self.gsub(/([a-z])([A-Z0-9])/, '\1-\2').downcase