# File lib/dnsruby/name.rb, line 66
    def self.punycode(d)
        begin
          c = Addressable::URI.parse("http://" + d.to_s)
          ret = c.normalized_host.sub("http://", "")
          if (!d.end_with?".")
            return ret.chomp(".")
          end
          if (!ret.end_with?".")
            return ret + "."
          end
          return ret
        rescue Exception => e
          return d
        end
    end