0.0
No commit activity in last 3 years
No release in over 3 years
Small utility that allows you to detect scripts (languages) in unicode text
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
 Project Readme

Gem Version unicode-script

Small utility that allows you to detect scripts (languages) in unicode text.

###Usage:

gem install unicode-script

Suppose you have a string

h = 'ひらがな'

then you can detect the script to which this string belongs:

UnicodeScript.detect(h) # => [{:script => 'Hiragana', :value => 'ひらがな'}]

It doesn't work well on strings with spaces and delimeters:

mixed_string = "This is latin, カタカナ and ひらがな"
UnicodeScript.detect(mixed_string) # => {:script=>"basic latin", :value=>"Thisislatin,and"} 
                                   #    {:script=>"katakana", :value=>"カタカナ"}
                                   #    {:script=>"hiragana", :value=>"ひらがな"}

You can also check if string belongs to certain script:

UnicodeScript.hiragana?(h) # => true
kanji = '漢字'
UnicodeScript.cjk_unified_ideographs?(kanji) # => true
UnicodeScript.katakana?(h) # => false