The project is in a healthy, maintained state
Detect the unicode script per character
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 7.2, >= 7.2.2
~> 2.5
 Project Readme

Unicode Script Detector

Detect all Unicode scripts in a text.

Installation

Add this line to your application's Gemfile:

gem "unicode_script_detector"

Or install it globally:

$ gem install unicode_script_detector

Detect all the characters of a string

UnicodeScriptDetector.detect_characters "Hel6б"

#Output:
[#<UnicodeScriptDetector::Character:0x00007768fefdead8 @char="H", @name="Latin", @script=:Latin>,
 #<UnicodeScriptDetector::Character:0x00007768fefdea10 @char="e", @name="Latin", @script=:Latin>,
 #<UnicodeScriptDetector::Character:0x00007768fefde970 @char="l", @name="Latin", @script=:Latin>,
 #<UnicodeScriptDetector::Character:0x00007768fefde8d0 @char="6", @name="Digit", @script=:Digit>,
 #<UnicodeScriptDetector::Character:0x00007768fefde830 @char="б", @name="Cyrillic", @script=:Cyrillic>]

Detect if a script contains certain scripts

# This will return true because it contains Latin and Cyrillic
UnicodeScriptDetector.contains? "Hellб🔥", [:Latin, :Cyrillic]

Detect if a script contains only certain scripts

# This will return false because it contains an Emoji as well
UnicodeScriptDetector.contains_only? "Hellб🔥", [:Latin, :Cyrillic]

Development

Start the console with bin/console. Run the tests with bin/test.

Contributing

You're welcome to contribute to this project. See https://github.com/davidarendsen/unicode_script_detector.

License

This software is released under the MIT license.