Eugene Yarmash Asked: 2011-11-27 14:59:07 +0800 CST2011-11-27 14:59:07 +0800 CST 2011-11-27 14:59:07 +0800 CST How can I convert an IDN to Punycode in bash? 772 What is the easiest way to convert an IDN (such as президент.рф) to Punycode in bash? linux bash idn 3 Answers Voted Best Answer quanta 2011-11-27T17:59:17+08:002011-11-27T17:59:17+08:00 Take a look at the idn: [U] net-dns/libidn Available versions: 1.22 (~)1.22-r1 {doc elibc_FreeBSD emacs java mono nls static-libs} Installed versions: 1.22(03:12:19 PM 07/04/2011)(nls static-libs -doc -elibc_FreeBSD -emacs -java -mono) Homepage: http://www.gnu.org/software/libidn/ Description: Internationalized Domain Names (IDN) implementation For e.g: $ echo "президент.рф" | idn xn--d1abbgf6aiiy.xn--p1ai Per von Zweigbergk 2011-11-27T15:09:37+08:002011-11-27T15:09:37+08:00 Assuming you have python on your system, python -c 'import sys;print sys.argv[1].decode("utf-8").encode("idna")' "президент.рф" would do the trick. zored 2016-12-14T05:05:47+08:002016-12-14T05:05:47+08:00 In MacOS brew install homebrew/versions/libidn2. Then echo "президент.рф" | idn2.
Take a look at the
idn
:For e.g:
Assuming you have python on your system,
python -c 'import sys;print sys.argv[1].decode("utf-8").encode("idna")' "президент.рф"
would do the trick.In MacOS
brew install homebrew/versions/libidn2
.Then
echo "президент.рф" | idn2
.