]> git.openstreetmap.org Git - rails.git/blob - lib/utf8.rb
Merge pull request #5932 from tomhughes/frozen-strings
[rails.git] / lib / utf8.rb
1 # frozen_string_literal: true
2
3 module UTF8
4   ##
5   # Checks that a string is valid UTF-8 by trying to convert it to UTF-8
6   # using the iconv library, which is in the standard library.
7   def self.valid?(str)
8     return true if str.nil?
9
10     str.valid_encoding?
11   end
12 end