source: subversion/sites/rails_port/lib/utf8.rb @ 20148

Last change on this file since 20148 was 16707, checked in by zere, 11 years ago

Added methods to strip those non-XML control characters from tags in AMF controller and give an error if there's invalid UTF-8.

File size: 302 bytes
1module UTF8
2  ##
3  # Checks that a string is valid UTF-8 by trying to convert it to UTF-8
4  # using the iconv library, which is in the standard library.
5  def self.valid?(str)
6    return true if str.nil?
7    Iconv.conv("UTF-8", "UTF-8", str)
8    return true
10  rescue
11    return false
12  end 
Note: See TracBrowser for help on using the repository browser.