Sha256: 4d7d1043dfe13f41918954f57a0d6519558f9d9d92b797f3d498cb2f023ab28c

Contents?: true

Size: 1.36 KB

Versions: 121

Compression:

Stored size: 1.36 KB

Contents

# 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.
class ActiveSupport::Multibyte::Handlers::UTF8HandlerProc < ActiveSupport::Multibyte::Handlers::UTF8Handler #:nodoc:
  class << self
    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
    
    def decompose(str) #:nodoc:
      utf8map(str, :stable)
    end
    
    def downcase(str) #:nodoc:c
      utf8map(str, :casefold)
    end
    
    protected
    
    def utf8map(str, *option_array) #:nodoc:
      options = 0
      option_array.each do |option|
        flag = Utf8Proc::Options[option]
        raise ArgumentError, "Unknown argument given to utf8map." unless
          flag
        options |= flag
      end
      return Utf8Proc::utf8map(str, options)
    end
  end
end

Version data entries

121 entries across 121 versions & 12 rubygems

Version Path
3mix-castronaut-0.5.0.2 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
masover-castronaut-0.4.4.4 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
masover-castronaut-0.4.4.5 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
masover-castronaut-0.5.0.1 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
relevance-castronaut-0.4.1 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
relevance-castronaut-0.4.2 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
relevance-castronaut-0.4.3 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
relevance-castronaut-0.4.4 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
relevance-castronaut-0.4.5 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
relevance-castronaut-0.4.6 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
relevance-castronaut-0.5.0 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
relevance-castronaut-0.5.1 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
relevance-castronaut-0.5.2 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
relevance-castronaut-0.5.3 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
relevance-castronaut-0.5.4 vendor/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
radiant-0.7.2 vendor/rails/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
vibes-bj-1.2.2 spec/rails_root/vendor/rails/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
vibes-bj-1.2.1 spec/rails_root/vendor/rails/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
jstorimer-deep-test-2.0.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb
jstorimer-deep-test-1.4.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb