Project

idna

0.0
Low commit activity in last 3 years
No release in over a year
Ruby FFI bindings for Libidn2.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1
~> 13.0
~> 3.12

Runtime

>= 0
 Project Readme

IDNA

Ruby FFI bindings for the libidn2 library, providing some simple methods to handle internationalised domain names backed by the GNU library's complete IDNA2008 / TR46 implementation.

The gem is tested with "latest at last test run" patch versions of Ruby 3.2. It is believed to work on Ruby 2.4 or later, but this is no longer automatically tested.

Installation

Add this line to your application's Gemfile:

gem 'idna'

And then execute:

$ bundle

Or install it yourself as:

$ gem install idna

You will need to install libidn2 separately, if it is not already installed on your system. For example, macOS users with Homebrew can run brew install libidn2.

Usage

Transform

  • Attach function to idn2_to_ascii_8z:
Idna.to_ascii('あいうえお') #xn--l8jegik
  • Attach function to idn2_to_unicode_8z8z:
Idna.to_unicode('xn--l8jegik') #あいうえお

Configure

  • Custom libidn2 name:
Idna.configure do |config|
  config.ffi_lib = 'idn2.so.11'
end

Idna.reload!

Development

$ bundle exec rspec

License

  • MIT