Class: ActiveSupport::Multibyte::Handlers::UTF8HandlerProc

Inherits:
UTF8Handler show all
Defined in:
lib/active_support/multibyte/handlers/utf8_handler_proc.rb

Overview

Methods in this handler call functions in the utf8proc ruby extension. These are significantly faster than the pure ruby versions. Chars automatically uses this handler when it can load the utf8proc extension. For documentation on handler methods see UTF8Handler.

Constant Summary

Constants inherited from UTF8Handler

ActiveSupport::Multibyte::Handlers::UTF8Handler::HANGUL_JAMO_FIRST, ActiveSupport::Multibyte::Handlers::UTF8Handler::HANGUL_JAMO_LAST, ActiveSupport::Multibyte::Handlers::UTF8Handler::HANGUL_LBASE, ActiveSupport::Multibyte::Handlers::UTF8Handler::HANGUL_LCOUNT, ActiveSupport::Multibyte::Handlers::UTF8Handler::HANGUL_NCOUNT, ActiveSupport::Multibyte::Handlers::UTF8Handler::HANGUL_SBASE, ActiveSupport::Multibyte::Handlers::UTF8Handler::HANGUL_SCOUNT, ActiveSupport::Multibyte::Handlers::UTF8Handler::HANGUL_SLAST, ActiveSupport::Multibyte::Handlers::UTF8Handler::HANGUL_TBASE, ActiveSupport::Multibyte::Handlers::UTF8Handler::HANGUL_TCOUNT, ActiveSupport::Multibyte::Handlers::UTF8Handler::HANGUL_VBASE, ActiveSupport::Multibyte::Handlers::UTF8Handler::HANGUL_VCOUNT, ActiveSupport::Multibyte::Handlers::UTF8Handler::UNICODE_LEADERS_AND_TRAILERS, ActiveSupport::Multibyte::Handlers::UTF8Handler::UNICODE_LEADERS_PAT, ActiveSupport::Multibyte::Handlers::UTF8Handler::UNICODE_TRAILERS_PAT, ActiveSupport::Multibyte::Handlers::UTF8Handler::UNICODE_WHITESPACE, ActiveSupport::Multibyte::Handlers::UTF8Handler::UTF8_PAT

Class Method Summary collapse

Methods inherited from UTF8Handler

[]=, capitalize, center, codepoints_to_pattern, compose, consumes?, g_length, index, insert, ljust, lstrip, reverse, rjust, rstrip, size, slice, strip, tidy_bytes, translate_offset, upcase

Class Method Details

.decompose(str) ⇒ Object

:nodoc:



22
23
24
# File 'lib/active_support/multibyte/handlers/utf8_handler_proc.rb', line 22

def decompose(str) #:nodoc:
  utf8map(str, :stable)
end

.downcase(str) ⇒ Object

:nodoc:c



26
27
28
# File 'lib/active_support/multibyte/handlers/utf8_handler_proc.rb', line 26

def downcase(str) #:nodoc:c
  utf8map(str, :casefold)
end

.normalize(str, form = ActiveSupport::Multibyte::DEFAULT_NORMALIZATION_FORM) ⇒ Object

:nodoc:



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/active_support/multibyte/handlers/utf8_handler_proc.rb', line 6

def normalize(str, form=ActiveSupport::Multibyte::DEFAULT_NORMALIZATION_FORM) #:nodoc:
  codepoints = str.unpack('U*')
  case form
    when :d
      utf8map(str, :stable)
    when :c
      utf8map(str, :stable, :compose)
    when :kd
      utf8map(str, :stable, :compat)
    when :kc
      utf8map(str, :stable, :compose, :compat)
    else
      raise ArgumentError, "#{form} is not a valid normalization variant", caller
  end
end