Skip to content

Instantly share code, notes, and snippets.

@Kwpolska
Created December 10, 2015 19:11
Show Gist options
  • Save Kwpolska/28c7a67c6839c8fbd71f to your computer and use it in GitHub Desktop.
Save Kwpolska/28c7a67c6839c8fbd71f to your computer and use it in GitHub Desktop.
IDNA vs Punycode
Python 3.5.1 (default, Dec 7 2015, 12:58:09)
Type "copyright", "credits" or "license" for more information.
IPython 4.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: 'ąbc.pl'.encode('punycode')
Out[1]: b'bc.pl-2wa'
In [2]: 'abc.pl'.encode('punycode')
Out[2]: b'abc.pl-'
In [3]: 'ąbc.pl'.encode('punycode')
Out[3]: b'bc.pl-2wa'
In [4]: 'ąbc.pl'.encode('idna')
Out[4]: b'xn--bc-ola.pl'
In [5]: 'abc.pl'.encode('punycode')
Out[5]: b'abc.pl-'
In [6]: 'abc.pl'.encode('idna')
Out[6]: b'abc.pl'
In [7]: 'ąbc'.encode('punycode')
Out[7]: b'bc-ola'
In [8]: 'ąbc'.encode('idna')
Out[8]: b'xn--bc-ola'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment