Skip to content
/ icunicode Public
forked from ninjudd/icunicode

ICU Unicode Transliteration and Collation in Ruby.

License

Notifications You must be signed in to change notification settings

geni/icunicode

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ICUnicode

Unicode sorting is complicated (unicode.org/reports/tr10), and Ruby doesn’t do it correctly. But there is a widely-used implementation of the Unicode collation algorithm in the ICU (International Components for Unicode) libraries. There is also no way to do Transliteration in Ruby (userguide.icu-project.org/transforms/general). This gem is a simple C wrapper around ucol_getSortKey from the ICU Collation API and utrans_transUChars from the ICU Transliteration API. These are added as simple methods on String.

Usage:

["cafe", "cafes", "caf\303\251"].sort
=> ["cafe", "cafes", "caf\303\251"]

require 'icunicode'

["cafe", "cafes", "caf\303\251"].sort_by {|s| s.unicode_sort_key}
=> ["cafe", "caf\303\251", "cafes"]

"blueberry".transliterate("Katakana").transliterate("Latin")
=> "burueberrui"

"blueberry".transliterate("Greek").transliterate("Latin")
=> "blyeberry"

Install:

You must install ICU first. You can download the source from site.icu-project.org/download, or on Mac, you can install with MacPorts:

sudo port install icu

Then install the gem:

sudo gem install icunicode

To do:

Add support for locales other than en-US. Increase buffer size or make it grow dynamically.

License:

Copyright © 2009 Justin Balthrop, Geni.com; Published under The MIT License, see LICENSE

About

ICU Unicode Transliteration and Collation in Ruby.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 59.2%
  • C 40.8%