simpleidn.cr

SimpleIDN crystal shard

simpleidn.cr

This is a Crystal port of the Ruby library simpleidn.

It provides easy conversion from punycode ACE strings to unicode strings and vice versa.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      simpleidn:
        github: cyangle/simpleidn.cr
    
  2. Run shards install

Note: This shard requires libicu to be installed on your system.

  • Ubuntu/Debian: sudo apt-get install libicu-dev
  • macOS: brew install icu4c

Usage

require "simpleidn"

# Convert to ASCII (Punycode)
SimpleIDN.to_ascii("møllerriis.com")
# => "xn--mllerriis-l8a.com"

# Convert to Unicode
SimpleIDN.to_unicode("xn--mllerriis-l8a.com")
# => "møllerriis.com"

# Handle mapped characters (UTS #46)
SimpleIDN.to_ascii("Faß.de")
# => "xn--fa-hia.de" (ss maps to ss)

SimpleIDN.to_unicode("xn--fa-hia.de")
# => "fass.de"

Development

To run tests:

crystal spec

To format the code:

crystal tool format

This project uses the icu shard for normalization and handling of special characters.

Contributing

  1. Fork it (https://github.com/cyangle/simpleidn.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

simpleidn.cr

Owner
Statistic
  • 0
  • 0
  • 0
  • 1
  • 1
  • 1 day ago
  • January 14, 2026
License

MIT License

Links
Synced at

Wed, 14 Jan 2026 04:12:45 GMT

Languages