Permalink
Browse files

Merge pull request #19124 from davydovanton/add-doc-for-is-utf8

[skip ci] Add documentation for String#is_utf8? method
  • Loading branch information...
guilleiguaran committed Feb 28, 2015
2 parents 8af9e1b + dde6ee9 commit c4551a5bbb2c4e0f2c321e3da5e019b054bbfa9e
Showing with 7 additions and 0 deletions.
  1. +7 −0 activesupport/lib/active_support/core_ext/string/multibyte.rb
@@ -35,6 +35,13 @@ def mb_chars
ActiveSupport::Multibyte.proxy_class.new(self)
end
# Return +true+ if string has utf_8 encoding.
#
# utf_8_str = "some string".encode "UTF-8"
# iso_str = "some string".encode "ISO-8859-1"
#
# utf_8_str.is_utf8? # => true
# iso_str.is_utf8? # => false
def is_utf8?
case encoding
when Encoding::UTF_8

0 comments on commit c4551a5

Please sign in to comment.