6

What is the easiest way to convert an IDN (such as президент.рф) to Punycode in bash?

PeterM
  • 103
  • 5
Eugene Yarmash
  • 2,433
  • 5
  • 34
  • 54

3 Answers3

12

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
quanta
  • 51,413
  • 19
  • 159
  • 217
3

Assuming you have python on your system, python -c 'import sys;print sys.argv[1].decode("utf-8").encode("idna")' "президент.рф" would do the trick.

Per von Zweigbergk
  • 2,625
  • 2
  • 19
  • 28
1

In MacOS brew install homebrew/versions/libidn2.

Then echo "президент.рф" | idn2.

zored
  • 121
  • 1