icu
Crystal ICU
Crystal binding/wrapper to the ICU library
Installation
Debian/Ubuntu
apt-get install -y libicu-dev
macOS
brew install icu4c
brew link --force icu4c
Usage
Add this to your application's shard.yml
:
dependencies:
icu:
github: olbat/icu.cr
Then require the lib in your Crystal code:
require "icu"
Wrapped components (WIP)
- [x] CharsetDetector, Charset detection (ucsdet.h)
- [x] BreakIterator, Text Boundary Analysis (Break Iteration) (ubrk.h)
- [x] Transliterator, Text Transformation (Transliteration) (utrans.h)
- [x] Normalizer, Normalization (unorm2.h)
- [x] Collator, Collation (ucol.h)
- [x] StringSearch, String Searching (usearch.h)
- [x] IDNA, International Domain Names in Applications (uidna.h)
- [x] Currencies, Encapsulates information about a currency (ucurr.h)
- [x] Region, Territory containment and mapping (uregion.h)
- [x] UniversalTimeScale, Universal Time Scale (utmscale.h)
- [ ]
uregex
, Regular Expressions (uregex.h) - [ ]
uloc
, Locales (uloc.h, ulocdata.h) - [ ]
unum
, Number Formatting/Spellout (unum.h) - [ ]
ubidi
, Bidirectional Algorithm (ubidi.h) - [ ]
ucnv
, Codepage Conversion (ucnv.h, ucnvsel.h) - [ ]
ucal
, Calendars (ucal.h) - [ ]
udat
, Date and Time Formatting (udat.h, udatpg.h, udateintervalformat.h) - [ ]
upluralrules
, Plural rules (upluralrules.h)
Internals
- [x] UChars, UChar conversion routines
- [x] UEnum, String Enumeration (uenum.h)
- [ ]
ustring
, Strings and Character Iteration (ustring.h, uiter.h) - [ ]
utext
, Abstract Unicode Text API (utext.h) - [ ]
uset
, Sets of Unicode Code Points and Strings (uset.h) - [ ]
ures
, Resource Bundles (ures.h) - [ ]
usprep
, StringPrep (usprep.h) - [ ]
uspoof
, Identifier Spoofing & Confusability (uspoof.h) - [ ]
udata
, Data loading interface (udata.h)
Development
ICU version compatibility
This binding is compatible with the ICU library starting from version 4.8
.
It has been generated using ICU version 57.1
so every additions in the API from this version will not be present in this binding.
The Crystal wrapper's (the ICU
class) class and methods are enabled dynamically at compile-time depending on the version of the ICU library that's installed.
Please make sure that the class/feature you want to use is supported by your version ICU by checking the API documentation.
Regenerate the binding
To be sure that the LibICU
binding fits with the version of the lib that's installed, it's possible to regenerate the binding by:
- Installing libgen and it's dependencies (cf. libgen's documentation)
- Run libgen and the lib_transformer program by running
make generate_lib
Project's structure
src/lib_icu
: this directory contains the binding to the ICU library, it's generated by libgen & a transformation programsrc/icu
: this directory contains the wrapper to theLibICU
crystal lib that eases the usage of the bindingsrc/icu_info.cr
: this small program is used to determine which version of ICU is installed on the system (see #1)src/lib_transformer.cr
: this small program is used to fix the binding generated by libgen (see #3)
About the binding's generation
For implementation and technical details about the binding's generation, see #1 & #3.
Contributing
- Fork it ( https://github.com/olbat/icu.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- olbat Luc Sarzyniec - creator, maintainer