Unicode::Confusable [version] [travis]

Compares two strings if they are visually confusable as described in Unicode® Technical Standard #39: Both strings get transformed into a skeleton format before comparing them. The skeleton is generated by normalizing the string, replacing confusable characters, and normalizing the string again. Please note: The skeleton is an intermediate representation, not meant for any other use than testing confusability.

Unicode version: 8.0.0

Supported Rubies: 2.3, 2.2

Gemfile

gem "unicode-confusable"

Usage

require "unicode/confusable"

Unicode::Confusable.confusable? "a", "b" # => false
Unicode::Confusable.confusable? "ℜ𝘂ᖯʏ", "Ruby" # => true
Unicode::Confusable.confusable? "Michael", "Michae1" # => true
Unicode::Confusable.confusable? "⁇", "?" # => false
Unicode::Confusable.confusable? "⁇", "??" # => true

No Advanced Detection

TR 39 also describes mechanisms for a more exact recognition of confusables, also within the same string:

  • Single-script confusable
  • Mixed-script confusable
  • Whole-script confusable

This is (currently) not supported by this gem.

MIT License