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 if ''.respond_to?("valid_encoding?")
7 return true if str.nil?
14 return true if str.nil?
15 Iconv.conv("UTF-8", "UTF-8", str)