Last active
August 29, 2015 13:57
-
-
Save anvyst/9637022 to your computer and use it in GitHub Desktop.
A quick script for fast conversion of punycode from/to ascii and unicode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -w | |
require 'simpleidn' | |
require 'getoptlong' | |
opts = GetoptLong.new( | |
[ '--help', '-h', GetoptLong::NO_ARGUMENT ], | |
[ '--unicode', '-u', GetoptLong::REQUIRED_ARGUMENT ], | |
[ '--ascii', '-a', GetoptLong::REQUIRED_ARGUMENT ] | |
) | |
opts.each do |opt, arg| | |
case opt | |
when '--help' | |
puts "For converting to punycode use --ascii [parameter]" | |
puts "For converting to unicode use --unicode [parameter]" | |
puts "Example: punycode --ascii пипец.рф" | |
when '--unicode' | |
puts "Result: #{SimpleIDN.to_unicode(arg)}" | |
when '--ascii' | |
puts "Result: #{SimpleIDN.to_ascii(arg)}" | |
else | |
puts "Call up for --help, you're getting crazy!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment