Method: StringUtils#mb_charify

Defined in:
lib/string_utils.rb

#mb_charify(text) ⇒ Object

Returns a unicode compatible version of the string

support any of:

* ruby 1.9 sane utf8 support
* rails 2.1 workaround for crappy ruby 1.8 utf8 support
* rails 2.2 workaround for crappy ruby 1.8 utf8 support

hooray!



152
153
154
155
156
157
158
159
160
# File 'lib/string_utils.rb', line 152

def mb_charify(text)
  if RUBY_VERSION >= '1.9'
    text.dup
  elsif text.respond_to?(:mb_chars)
    text.frozen? ? text.dup.mb_chars : text.mb_chars
  else
    raise "StringUtils: No unicode support for strings"
  end
end