class ICU::IDNA

Overview

International Domain Names in Applications

Implements UTS #46 and IDNA2008.

Usage

dn = ICU::IDNA.to_ascii("افغانستا.icom.museum")                             # => "xn--mgbaal8b0b9b2b.icom.museum"
ICU::IDNA.to_unicode(dn)                                                    # => "افغانستا.icom.museum"
ICU::IDNA.compare("افغانستا.icom.museum", "xn--mgbaal8b0b9b2b.icom.museum") # => 0

See also

Defined in:

icu/idna.cr

Class Method Summary

Class Method Detail

def self.compare(idn1 : String, idn2 : String, options : UInt32 = Option::Default.to_u32) : Int #

Compares two IDN strings (that can be in unicode or ascii representation)

ICU::IDNA.compare("افغانستا.icom.museum", "xn--mgbaal8b0b9b2b.icom.museum") # => 0

(see String#compare)


[View source]
def self.to_ascii(unicode_idn : String, options : UInt32 = Option::Default.to_u32) : String #

Converts a Unicode IDN to it's ASCII representation

ICU::IDNA.to_ascii("افغانستا.icom.museum") # => "xn--mgbaal8b0b9b2b.icom.museum"

[View source]
def self.to_unicode(ascii_idn : String, options : UInt32 = Option::Default.to_u32) : String #

Converts an ASCII IDN to it's Unicode representation

ICU::IDNA.to_unicode("xn--mgbaal8b0b9b2b.icom.museum") # => "افغانستا.icom.museum"

[View source]