2014-10-06 00:44:31 +03:00
|
|
|
.. _example_idna:
|
|
|
|
|
|
|
|
Internationalized domain name support
|
2017-06-16 13:16:05 +03:00
|
|
|
=====================================
|
2014-10-06 00:44:31 +03:00
|
|
|
|
|
|
|
Unlike the libUnbound, pyUnbound is able to handle IDN queries.
|
|
|
|
|
2017-06-16 13:16:05 +03:00
|
|
|
Automatic IDN DNAME conversion
|
|
|
|
-------------------------------
|
2014-10-06 00:44:31 +03:00
|
|
|
|
2017-06-16 13:16:05 +03:00
|
|
|
If we use unicode string in :meth:`unbound.ub_ctx.resolve` method,
|
|
|
|
the IDN DNAME conversion (if it is necessary) is performed on background.
|
2014-10-06 00:44:31 +03:00
|
|
|
|
2017-06-16 13:16:05 +03:00
|
|
|
Source code
|
|
|
|
...........
|
2014-10-06 00:44:31 +03:00
|
|
|
|
2017-06-16 13:16:05 +03:00
|
|
|
.. literalinclude:: example7-1.py
|
|
|
|
:language: python
|
|
|
|
|
|
|
|
IDN converted attributes
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
The :class:`unbound.ub_data` class contains attributes suffix which converts
|
|
|
|
the dname to UTF string. These attributes have the ``_idn`` suffix.
|
|
|
|
|
|
|
|
Apart from this aproach, two conversion functions exist
|
|
|
|
(:func:`unbound.idn2dname` and :func:`unbound.dname2idn`).
|
|
|
|
|
|
|
|
Source code
|
|
|
|
...........
|
|
|
|
|
|
|
|
.. literalinclude:: example7-2.py
|
|
|
|
:language: python
|