From dde6ee9e9b4c04aa56350b34ae74bb0ad0cf8420 Mon Sep 17 00:00:00 2001 From: Anton Davydov Date: Sat, 28 Feb 2015 16:28:54 +0300 Subject: [skip ci] Add documentation for String#is_utf8? method --- activesupport/lib/active_support/core_ext/string/multibyte.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/string/multibyte.rb b/activesupport/lib/active_support/core_ext/string/multibyte.rb index 2eedd4fdb1..57d7f8d1e7 100644 --- a/activesupport/lib/active_support/core_ext/string/multibyte.rb +++ b/activesupport/lib/active_support/core_ext/string/multibyte.rb @@ -35,6 +35,13 @@ class String 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 -- cgit v1.2.3