xref: /netbsd-src/external/bsd/unbound/dist/libunbound/python/doc/examples/example7.rst (revision 0cd9f4ecf44538bbdd5619b5b2081449960ab3e6)
1.. _example_idna:
2
3Internationalized domain name support
4=====================================
5
6Unlike the libUnbound, pyUnbound is able to handle IDN queries.
7
8Automatic IDN DNAME conversion
9-------------------------------
10
11If we use unicode string in :meth:`unbound.ub_ctx.resolve` method,
12the IDN DNAME conversion (if it is necessary) is performed on background.
13
14Source code
15...........
16
17.. literalinclude:: example7-1.py
18    :language: python
19
20IDN converted attributes
21------------------------
22
23The :class:`unbound.ub_data` class contains attributes suffix which converts
24the dname to UTF string. These attributes have the ``_idn`` suffix.
25
26Apart from this approach, two conversion functions exist
27(:func:`unbound.idn2dname` and :func:`unbound.dname2idn`).
28
29Source code
30...........
31
32.. literalinclude:: example7-2.py
33    :language: python
34