Sha256: 9f13ceb18edb5f9284055207eed10e711b7e64922d3f6948b15c8c7090208c27

Contents?: true

Size: 585 Bytes

Versions: 1

Compression:

Stored size: 585 Bytes

Contents

require_relative "confusable/constants"
require_relative "confusable/index"

require 'unicode_normalize/normalize'

module Unicode
  module Confusable
    def self.confusable?(string1, string2)
      skeleton(string1) == skeleton(string2)
    end

    def self.skeleton(string)
      require_relative 'display_width/index' unless defined? ::Unicode::Confusable::INDEX
      UnicodeNormalize.normalize(
        UnicodeNormalize.normalize(string, :nfd).each_codepoint.map{ |codepoint|
          INDEX[codepoint] || codepoint
        }.flatten.pack("U*"), :nfd
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unicode-confusable-1.0.0 lib/unicode/confusable.rb