]> git.openstreetmap.org Git - rails.git/blobdiff - lib/utf8.rb
Added methods to strip those non-XML control characters from tags in AMF controller...
[rails.git] / lib / utf8.rb
diff --git a/lib/utf8.rb b/lib/utf8.rb
new file mode 100644 (file)
index 0000000..5f0d219
--- /dev/null
@@ -0,0 +1,14 @@
+module UTF8
+  ##
+  # Checks that a string is valid UTF-8 by trying to convert it to UTF-8
+  # using the iconv library, which is in the standard library.
+  def self.valid?(str)
+    return true if str.nil?
+    Iconv.conv("UTF-8", "UTF-8", str)
+    return true
+    
+  rescue
+    return false
+  end  
+end
+