idnkit-python  2.3
Public Member Functions | List of all members
idnkit.IDNA2008 Class Reference

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...
 

Detailed Description

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.

Member Function Documentation

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.

Parameters
nameA domain name to be validated.
actionsAn Action value to encode 'name'.
Returns
True if the domain name is valid.
Exceptions
idnkit.ErrorConversion 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.

Parameters
name1A domain name #1.
name2A domain name #2.
actions1An Action value to encode 'name1'.
actions2An Action value to encode 'name2'.
Returns
True if two domain names are equivalent.
Exceptions
idnkit.ErrorConversion 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.

Parameters
actionsAn action value to decode 'name'.
nameA domain name to be decoded.
Returns
A decoded domain name.
Exceptions
idnkit.ErrorConversion 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.

Parameters
actionsAn action value to encode 'name'.
nameA domain name to be encoded.
Returns
An encoded domain name.
Exceptions
idnkit.ErrorConversion failed.
def idnkit.IDNA2008.get_idna_table_version ( )

Gets a version of IDNA tables the context instance supports.

Returns
Version (e.g. "rfc6452 (2011-11-14)").
def idnkit.IDNA2008.get_lib_idn_version ( )

Gets a version of idnkit library.

Returns
Version (e.g. "2.2" for idnkit version 2.2).
def idnkit.IDNA2008.get_unicode_version ( )

Gets a version of Unicode tables the context instance supports.

Returns
Version (e.g. "6.0.0" in case of Unicode 6.0.0).
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.

Returns
Version string.
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.

Parameters
filenameConfiguration file to be read.
Exceptions
idnkit.ErrorInitialization 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.

Parameters
filenameCode point set file to be read.
Exceptions
idnkit.ErrorFailed to read the file.

The documentation for this class was generated from the following file: