https://github.com/HoneyryderChuck/idnx
Encode and decode internationalized domain names using libidn2, winnls and ruby FFI
https://github.com/HoneyryderChuck/idnx
ffi idna libidn2 ruby
Last synced: 10 months ago
JSON representation
Encode and decode internationalized domain names using libidn2, winnls and ruby FFI
- Host: GitHub
- URL: https://github.com/HoneyryderChuck/idnx
- Owner: HoneyryderChuck
- License: apache-2.0
- Created: 2021-06-03T22:15:25.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-29T13:51:45.000Z (about 2 years ago)
- Last Synced: 2024-11-19T21:36:25.010Z (over 1 year ago)
- Topics: ffi, idna, libidn2, ruby
- Language: Ruby
- Homepage:
- Size: 41 KB
- Stars: 11
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Idnx
[](http://rubygems.org/gems/idnx)
[](https://github.com/HoneyryderChuck/idnx/actions/workflows/test.yml)
`idnx` provides a Ruby API for decoding Internationalized domain names into Punycode.
It provides multi-platform support by using the most approriate strategy based on the target environment:
* It uses (and requires the installation of) [libidn2](https://github.com/libidn/libidn2) in Linux / MacOS;
* It uses [the appropriate winnls APIs](https://docs.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-idntoascii) in Windows;
* It falls back to a pure ruby Punycode 2003 implementation;
## Installation
If you're on Linux or Mac OS, you'll have to install `libidn2` first:
```
# Mac OS
> brew install libidn2
# Ubuntu, as an example
> apt-get install idn2
```
Add this line to your application's Gemfile:
```ruby
gem 'idnx'
```
And then execute:
$ bundle install
Or install it yourself as:
$ gem install idnx
## Usage
```ruby
require "idnx"
Idnx.to_punycode("bücher.de") #=> "xn--bcher-kva.de"
```
## Ruby Support Policy
This library supports at least ruby 2.4 .It also supports both JRuby and Truffleruby.
## Known Issues
### JRuby on MacOS
`idnx` won't work in MacOS when using JRuby 9.2 or lower, due to jruby FFI not having the same path lookup logic than it's counterpart for CRuby, thereby not finding `brew`-installed `libidn2`. This has been fixed since JRuby 9.3 .
## Development
If you want to contribute, fork this project, and submit changes via a PR on github.
For running tests, you can run `rake test`.
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/HoneyryderChuck/idnx.