Class: Multibyte::Handlers::UTF8HandlerProc

Inherits:
UTF8Handler
  • Object
show all
Defined in:
lib/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

Multibyte::Handlers::UTF8Handler::HANGUL_JAMO_FIRST, Multibyte::Handlers::UTF8Handler::HANGUL_JAMO_LAST, Multibyte::Handlers::UTF8Handler::HANGUL_LBASE, Multibyte::Handlers::UTF8Handler::HANGUL_LCOUNT, Multibyte::Handlers::UTF8Handler::HANGUL_NCOUNT, Multibyte::Handlers::UTF8Handler::HANGUL_SBASE, Multibyte::Handlers::UTF8Handler::HANGUL_SCOUNT, Multibyte::Handlers::UTF8Handler::HANGUL_SLAST, Multibyte::Handlers::UTF8Handler::HANGUL_TBASE, Multibyte::Handlers::UTF8Handler::HANGUL_TCOUNT, Multibyte::Handlers::UTF8Handler::HANGUL_VBASE, Multibyte::Handlers::UTF8Handler::HANGUL_VCOUNT, Multibyte::Handlers::UTF8Handler::UNICODE_LEADERS_AND_TRAILERS, Multibyte::Handlers::UTF8Handler::UNICODE_LEADERS_PAT, Multibyte::Handlers::UTF8Handler::UNICODE_TRAILERS_PAT, Multibyte::Handlers::UTF8Handler::UNICODE_WHITESPACE, 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/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/multibyte/handlers/utf8_handler_proc.rb', line 26

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

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

:nodoc:



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

def normalize(str, form=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