Module: ActiveSupport::CoreExtensions::String::Multibyte

Included in:
String
Defined in:
lib/active_support/core_ext/string/multibyte.rb

Overview

Implements multibyte methods for easier access to multibyte characters in a String instance.

Instance Method Summary collapse

Instance Method Details

#charsObject


57
58
59
60
# File 'lib/active_support/core_ext/string/multibyte.rb', line 57

def chars
  ActiveSupport::Deprecation.warn('String#chars has been deprecated in favor of String#mb_chars.', caller)
  mb_chars
end

#is_utf8?Boolean

:nodoc

Returns:

  • (Boolean)

52
53
54
# File 'lib/active_support/core_ext/string/multibyte.rb', line 52

def is_utf8?
  ActiveSupport::Multibyte::Chars.consumes?(self)
end

#mb_charsObject

:nodoc


42
43
44
45
46
47
48
# File 'lib/active_support/core_ext/string/multibyte.rb', line 42

def mb_chars
  if ActiveSupport::Multibyte.proxy_class.wants?(self)
    ActiveSupport::Multibyte.proxy_class.new(self)
  else
    self
  end
end