---
name: "MDN::ResConf"
section: "3pm"
platform: "linux"
package: "libmdn-perl"
version: "2.4-2"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/MDN::ResConf"
---

# MDN::ResConf(3pm)

Perl interface to domain name conversion methods of libmdn

## NAME

MDN::ResConf - Perl interface to domain name conversion methods of libmdn

## SYNOPSIS

```
  use MDN::ResConf;
  $res = MDN::ResConf->new();
  $res->load_file('/usr/local/etc/mdn.conf');
```

```
  $idn_domain_name = $res->local_to_idn($local_domain_name);
  $local_domain_name = $res->idn_to_local($idn_domain_name);
```

## DESCRIPTION

`"MDN::ResConf"` provides a Perl object interface to domain name conversion methods of libmdn, the multilingual domain name library included in the mDNkit.

This module provides low-level conversion interface to the library.

## CONSTRUCTOR

- new

  Creates an object. It returns `"undef"` if no enough memory is remained.

## METHODS

- load\_file(\[$filename\])

  Loads a configuration file. If `$filename` is omitted, the default file (e.g. */usr/local/etc/mdn.conf*) is loaded.

- set\_local\_encoding(\[$encoding \[, @options\]\])

  Sets local encoding. If no encoding name is specified, the library determines it using locale information.

  The library currently understands two options, `'delayedopen'` and `'rtcheck'`. `'delayedopen'` delays opening the internal *iconv* converter until the conversion is actually performed. `'rtcheck'` enables round trip check, which is to ensure that the conversion is correctly performed.

  The method returns 1 upon success, `"undef"` otherwise.

- set\_idn\_encoding($encoding \[, @options\])

  Sets IDN encoding name (e.g. `'AMC-ACE-Z'`). The meaning of `@options` is the same as that of `"set_local_encoding"`. This method corresponds with `"idn-encoding"` entry in libmdn configuration file.

  It returns 1 upon success, `"undef"` otherwise.

- set\_nameprep\_version($version)

  Sets NAMEPREP version (e.g. `'nameprep-07'`). This method corresponds with `"nameprep"` entry in libmdn configuration file.

  It returns 1 upon success, `"undef"` otherwise.

- add\_delimiter\_map(@ucs)

  Recoginzes specified UCS code points (e.g. `0x3002`) as domain name delimiter. This method corresponds with `"delimiter-map"` entry in libmdn configuration file.

  It returns 1 upon success, `"undef"` otherwise.

- add\_local\_map($tld, @names)

  Add elements in `@names` (e.g. `'filemap:/some/where'`) to a list of local mapping schemes for the top level domain `$tld` (e.g. `'jp'`). This method corresponds with `"local-map"` entry in libmdn configuration file.

  It returns 1 upon success, `"undef"` otherwise.

- add\_nameprep\_map(@names)

  Add elements in `@names` (e.g. `'nameprep-07'`) to a list of NAMEPREP mapping schemes. This method corresponds with `"nameprep-map"` entry in libmdn configuration file.

  It returns 1 upon success, `"undef"` otherwise.

- add\_nameprep\_normalize(@names)

  Add elements in `@names` (e.g. `'unicode-form-kc'`) to a list of NAMEPREP normalization schemes. This method corresponds with `"nameprep-normalize"` entry in libmdn configuration file.

  It returns 1 upon success, `"undef"` otherwise.

- add\_nameprep\_prohibit(@names)

  Add elements in `@names` (e.g. `'fileset:/some/where'`) to a list of NAMEPREP prohibited-character check schemes. This method corresponds with `"nameprep-prohibit"` entry in libmdn configuration file.

  It returns 1 upon success, `"undef"` otherwise.

- add\_nameprep\_unassigned(@names)

  Add elements in `@names` (e.g. `'nameprep-07'`) to a list of NAMEPREP unassigned-codepoint check schemes. This method corresponds with `"nameprep-unassigned"` entry in libmdn configuration file.

  It returns 1 upon success, `"undef"` otherwise.

- *unset\_local\_encoding()*

  Unsets local encoding name, set by `"set_local_encoding"` method.

- *unset\_idn\_encoding()*

  Unsets IDN encoding name, set by `"set_idn_encoding"` method or `"idn-encoding"` entry in the loaded configuration file.

- *unset\_nameprep\_version()*

  Unsets NAMEPREP version, set by `"set_nameprep_version"` method or `"nameprep"` entry in the loaded configuration file.

  This methods unsets all of the NAMEPREP mapping, normalization, prohibited-character check and unassigned-codepoint check schemes, registered in the object.  Therefore,

  ```
      $res->unset_nameprep_version();
  ```

  is equivalent to the following codes:

  ```
      $res->unset_nameprep_map();
      $res->unset_nameprep_normalize();
      $res->unset_nameprep_prohibit();
      $res->unset_nameprep_unassigned();
  ```

- *unset\_delimiter\_map()*

  Unset delimiters, registered by `"add_delimiter_map"` method or `"delimiter-map"` entries in the loaded configuration file.

- *unset\_local\_map()*

  Unsets local mapping schemes, registered by `"add_local_map"` method or `"local-map"` entries in the loaded configuration file.

- *unset\_nameprep\_map()*

  Unsets NAMEPREP mapping schemes, registered by `"add_nameprep_map"` method or `"nameprep-map"` entries in the loaded configuration file.

- *unset\_nameprep\_normalize()*

  Unsets NAMEPREP normalization schemes, registered by `"add_nameprep_normalize"` method or `"nameprep-normalize"` entries in the loaded configuration file.

- *unset\_nameprep\_prohibit()*

  Unsets NAMEPREP prohibited-codepoint check schemes, registered by `"add_nameprep_prohibit"` method or `"nameprep-prohibit"` entries in the loaded configuration file.

- *unset\_nameprep\_unassigned()*

  Unsets NAMEPREP unassigned-codepoint check schemes, set by `"add_nameprep_unassigned"` method or `"nameprep-unassigned"` entries in the loaded configuration file.

- nameconv($instructions, $from)

  Converts a domain name `$from` according with `$instructions`, and returns the result. Similer to `"pack"` and `"unpack"`, `$instructions` is a sequence of characters listed below:

  ```
      l       convert the local encoding to UTF-8.
      L       convert the UTF-8 to the local encoding.
      d       covnert local delimiters to periods ('.').
      M       perfrom local mapping.
      m       perform the NAMEPREP mapping.
      n       perform NAMEPREP normalization.
      p       check whether the string contains NAMEPREP prohibited
              character.
      u       check whether the string contains NAMEPREP unassigned
              codepoint.
      N       perform NAMEPREP (equivalent to 'mnpu').
      I       convert the UTF-8 string to ACE.
      i       convert the ACE string to UTF-8.
      !m      inspect if NAMEPREP mapping has been performed to the
              string.  If hasn't, convert the string to ACE.
      !n      inspect if NAMEPREP normalizaion has been performed
              to the string.  If hasn't, convert the string to ACE.
      !p      search the string for NAMEPREP prohibited character.
              If found, convert the string to ACE.
      !u      search the string for NAMEPREP unassigned codepoint.
              If found, convert the string to ACE.
      !N      inspect if NAMEPREP has been performed to the string.
              If hasn't, convert the string to ACE. (equivalent to
              `!m!n!p!u').
  ```

  The characters in `$instructions` are applied left to right.

- enable($on\_off)

  Enable or disable mulitilingual domain name support provided by libmdn. If `$on_off` is zero, the support is disabled, otherwise enabled. If this method has not been called, the `"MDN_DISABLE"` environment variabe is used to determine whether mulitilingual domain name support is enabled. The support is disabled if that variable is defined,

  In disabled condition, conversion methods (e.g. `"nameconv()"`) simply return a copy of input string as the result of conversion.

- local\_to\_utf8($from)

  Is equivalent to `"nameconv('l', $from)"`.

- utf8\_to\_local($from)

  Is equivalent to `"nameconv('L', $from)"`.

- delimiter\_map($from)

  Is equivalent to `"nameconv('d', $from)"`.

- local\_map($from)

  Is equivalent to `"nameconv('M', $from)"`.

- map($from)

  Is equivalent to `"nameconv('m', $from)"`.

- normalize($from)

  Is equivalent to `"nameconv('n', $from)"`.

- prohibit\_check($from)

  Is equivalent to `"nameconv('p', $from)"`.

- unassigned\_check($from)

  Is equivalent to `"nameconv('u', $from)"`.

- nameprep($from)

  Is equivalent to `"nameconv('N', $from)"`.

- nameprep\_check($from)

  Is equivalent to `"nameconv('!N', $from)"`.

- utf8\_to\_idn($from)

  Is equivalent to `"nameconv('I', $from)"`.

- idn\_to\_utf8($from)

  Is equivalent to `"nameconv('i', $from)"`.

- local\_to\_idn($from)

  Is equivalent to `"nameconv('ldMNI', $from)"`.

- idn\_to\_local($from)

  Is equivalent to `"nameconv('i!NL', $from)"`.

## CLASS METHOD

- *lasterror()*

  Returns the error message string corresponding to the last error occurred in this module.

## COMPATIBILITY

Beginning with version 2.4, the instructions `'N'` and `'!N'` of the `"nameconv()"` method also perform unassigned codepoint check.

## ISSUE OF HANDLING UNICODE CHARACTERS

See the \`\`ISSUE OF HANDLING UNICODE CHARACTERS'' section in MDN::UTF8.

## SEE ALSO

[*mdn.conf*(5)](/mdn.conf/5.md), MDN::API, MDN::UTF8

MDN library specification
