File: example7.rst

package info (click to toggle)
unbound 1.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,436 kB
  • sloc: ansic: 138,476; sh: 6,860; yacc: 4,259; python: 1,950; makefile: 1,881; awk: 162; perl: 158; xml: 36
file content (33 lines) | stat: -rw-r--r-- 844 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
.. _example_idna:

Internationalized domain name support
=====================================

Unlike the libUnbound, pyUnbound is able to handle IDN queries.

Automatic IDN DNAME conversion
-------------------------------

If we use unicode string in :meth:`unbound.ub_ctx.resolve` method,
the IDN DNAME conversion (if it is necessary) is performed on background.

Source code
...........

.. 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 approach, two conversion functions exist
(:func:`unbound.idn2dname` and :func:`unbound.dname2idn`).

Source code
...........

.. literalinclude:: example7-2.py
    :language: python