Class: UnicodeMultibyte::Multibyte::Handlers::UTF8HandlerProc

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

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

Class Method Summary collapse

Methods inherited from UTF8Handler

capitalize, codepoints_to_pattern, compose, consumes?, g_length, index, insert, lstrip, reverse, rstrip, size, slice, strip, tidy_bytes, translate_offset, upcase

Class Method Details

.decompose(str) ⇒ Object

:nodoc:



23
24
25
# File 'lib/unicodechars/multibyte/handlers/utf8_handler_proc.rb', line 23

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

.downcase(str) ⇒ Object

:nodoc:c



27
28
29
# File 'lib/unicodechars/multibyte/handlers/utf8_handler_proc.rb', line 27

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

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

:nodoc:



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

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