Method: Addressable::IDNA.to_unicode
- Defined in:
-
lib/addressable/idna/pure.rb,
lib/addressable/idna/native.rb
Converts from an ASCII domain name to a Unicode internationalized domain name as described in RFC 3490.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/addressable/idna/pure.rb', line 88 def self.to_unicode(input) input = input.to_s unless input.is_a?(String) parts = input.split('.') parts.map! do |part| if part =~ /^#{ACE_PREFIX}(.+)/ begin punycode_decode(part[/^#{ACE_PREFIX}(.+)/, 1]) rescue Addressable::IDNA::PunycodeBadInput # toUnicode is explicitly defined as never-fails by the spec part end else part end end output = parts.join('.') if output.respond_to?(:force_encoding) output.force_encoding(Encoding::UTF_8) end output end |