idnkit-python
2.3
|
An instance of IDNA2008 class represents IDNA2008 version of IDNA conversion context. More...
Public Member Functions | |
def | init |
Initializes the instance of IDNA2008 conversion context. More... | |
def | set_local_check_file |
Reads a code point set for local-check from a file 'filename'. More... | |
def | encode |
Converts a domain name 'name' to ASCII and returns the result. More... | |
def | decode |
Converts a domain name 'name' to UTF-8 and returns the result. More... | |
def | compare |
Compares two domain names. More... | |
def | check |
Validates a domain name. More... | |
def | get_unicode_version |
Gets a version of Unicode tables the context instance supports. More... | |
def | get_idna_table_version |
Gets a version of IDNA tables the context instance supports. More... | |
def | get_lib_idn_version |
Gets a version of idnkit library. More... | |
def | get_version |
Returns version information. More... | |
An instance of IDNA2008 class represents IDNA2008 version of IDNA conversion context.
Its main functions are encoding (conversion to ASCII) and decoding (conversion to UTF-8) domain names, according with RFC5894; "Internationalized Domain Names in Applications (IDNA): Protocol".
Note that IDNA2008 class doesn't provide a constructor. To create an IDNA2008 instance, use the create() method of the idnkit module.
def idnkit.IDNA2008.check | ( | name, | |
actions = CHECK_REGIST |
|||
) |
Validates a domain name.
It tries to encode 'name' with an action value 'actions'. If succeeded, it returns true. Otherwise, it returns false.
name | A domain name to be validated. |
actions | An Action value to encode 'name'. |
idnkit.Error | Conversion of domain names failed. |
def idnkit.IDNA2008.compare | ( | name1, | |
name2, | |||
actions1 = COMPARE_LOOKUP , |
|||
actions2 = actions1 |
|||
) |
Compares two domain names.
It encodes domain names 'name1' and 'name2' as the encode() method does, and then compares them. If they are equivalent, it returns true. Otherwise, it returns false. The method performs 'actions1' to encode 'name1', and 'actions2' to encode 'name2' respectively.
name1 | A domain name #1. |
name2 | A domain name #2. |
actions1 | An Action value to encode 'name1'. |
actions2 | An Action value to encode 'name2'. |
idnkit.Error | Conversion of domain names failed. |
def idnkit.IDNA2008.decode | ( | name, | |
actions = DECODE_REGIST |
|||
) |
Converts a domain name 'name' to UTF-8 and returns the result.
The argument 'actions' specifies how 'name' is decoded.
actions | An action value to decode 'name'. |
name | A domain name to be decoded. |
idnkit.Error | Conversion failed. |
def idnkit.IDNA2008.encode | ( | name, | |
actions = ENCODE_REGIST |
|||
) |
Converts a domain name 'name' to ASCII and returns the result.
The argument 'actions' specifies how 'name' is encoded.
actions | An action value to encode 'name'. |
name | A domain name to be encoded. |
idnkit.Error | Conversion failed. |
def idnkit.IDNA2008.get_idna_table_version | ( | ) |
Gets a version of IDNA tables the context instance supports.
def idnkit.IDNA2008.get_lib_idn_version | ( | ) |
Gets a version of idnkit library.
def idnkit.IDNA2008.get_unicode_version | ( | ) |
Gets a version of Unicode tables the context instance supports.
def idnkit.IDNA2008.get_version | ( | ) |
Returns version information.
It returns a string which consists of a version of Unicode tables, a version of IDNA tables and a version of idnkit library.
def idnkit.IDNA2008.init | ( | filename = None | ) |
Initializes the instance of IDNA2008 conversion context.
The context will be initialized according with the configuration file specified by the argument 'filename'. If 'filename' is None, the context will have the default settings upon return. If 'filename' is not None but empty, the context reads the configuration file of the default path.
filename | Configuration file to be read. |
idnkit.Error | Initialization failed. |
def idnkit.IDNA2008.set_local_check_file | ( | filename = None | ) |
Reads a code point set for local-check from a file 'filename'.
If 'filename' is None, the local code point set the conversion context memories is cleared.
filename | Code point set file to be read. |
idnkit.Error | Failed to read the file. |