MDNCONV(1)

NAME
mdnconv - codeset converter for named.conf and zone master files

SYNOPSIS
mdnconv [options..] [file...]

DESCRIPTION
mdnconv is a codeset converter for named configuration files and zone master files. mdnconv performs codeset conversion specified by the command-line arguments, and writes the converted text to stdout. If file name is specified, mdnconv converts the contents of the file. Otherwise, mdnconv converts stdin.

mdnconv is specifically designed for converting internatinalized domain names, and may not be suitable as a general codeset converter.

OPTIONS

-in in-code
    Specify the codeset name of the input text. Any of the following codeset names can be specified.

    •   Codeset names which iconv_open() library function accepts

    •   ``UTF-5''

    •   ``RACE''

    •   ``BRACE''

    •   ``LACE''

    •   Any alias names for the above, defined by the codeset alias file.

    If this option is not specified, the default codeset is determined from the current locale.

-out out-code
    Specify the codeset name of the output text. out-code can be any codeset name that can be specified for -in option. If this option is not specified, the default is the codeset specified in MDN resolver configuration file (``server-encoding'' line).

-normalize scheme
    Perform normalization specified by scheme. Currently, following schemes are available:

    ``ascii-uppercase''
        ASCII lowercase to uppercase mapping.

    ``ascii-lowercase''
        ASCII uppercase to lowercase mapping.

    ``unicode-uppercase''
        Unicode lowercase to uppercase mapping, which is described in ``Unicode Technical Report #21: Case Mappings'', available from unicode.org.

    ``unicode-lowercase''
        Unicode uppercase to lowercase mapping, according ``Case Mappings''.

    ``unicode-form-c''
        Unicode Normlization Form C, which is described in ``Unicode Technical Report #15: Unicode Normalization Forms'', also available from unicode.org.

    ``unicode-form-kc''
        Perform Unicode Normlization Form KC, also described in the above document.

    ``ja-compose-voiced-sound''
        Compose Japanese full-width hiragana/katakana character and the following (semi) voiced sound mark (dakuten or han-dakuten in Japanese) into a single combined letter if such letter exists.

    ``ja-kana-fullwidth''
        Convert Japanese half-width katakana characters (aka ``hankaku katakana'') to their corresponding full-width characters.

    ``ja-alnum-halfwidth''
        Convert full-width alphabets, digits and minus sign to half-width.

    ``ja-minus-hack''
        Convert Japanese full-width minus sign (U+2212 ``MINUS SIGN'') to ``-'' (U+002D ``HYPHEN-MINUS'').

    ``ja-delimiter-hack''
        Map ``IDEOGRAPHIC FULL STOP'' (U+3002) and ``FULLWIDTH FULL STOP'' (U+FF0E) characters to period (``.'') so that these two characters can be used as domain component separaters.
        Note that there is no good reason to use this scheme when you convert configuration files or zone files, and its use is strongly deprecated.

    This option can be specified more than once. In that case, each normalization will be performed in the order of the specification.
    If this option is not specified, the schemes specified in MDN resolver configuration file (``normalize'' line) are used.

-zld ZLD
    Specify ZLD (zero-level domain) to use. If a domain name to be converted ends with the specified ZLD, the matching part will not be converted. This is important for some codesets such as UTF-5, in order to protect ZLD part intact from conversion.
    If this option is not specified, the default is the one specified in MDN resolver configuration file (``server-zld'' line) or empty (no ZLD).

-auto
    Automatically append ZLD specified by -zld option to domain names, if they contain non-ASCII character and end with period (``.''). By using this option, you don't have to specify ZLD explicitly in your zone master file. It is not perfect though, there are cases you have to write ZLD explicitly. So take care.

-whole
    Perform normalization and conversion to output codeset for the entire input text. If this option is not specified, only non-ASCII characters and their surrounding texts will be normalized and converted. See ``CONVERSION MECHANISM'' for details.

-alias path
    Specify a codeset alias file. It is a simple text file, where each line has a pair of alias name and real name separated by one or more white spaces like below:
        some-alias-codeset-name    real-codeset-name
    Lines starting with ``#'' are treated as comments.

-conf path
    Specify a MDN resolver configuration file (``mdnres.conf''). If not specified, system's default file is used.

-noconf
    Specify that no configuration file is to be used.

-flush
    Force line-buffering mode.

CONVERSION MECHANISM
Here is a brief step-by-step description of how mdnconv does its job.

1. input-side convnersion
    mdnconv reads input text line by line, and converts them from the input codeset to UTF-8 encoding. Basically this conversion is done using iconv() utility, but for some special codesets like UTF-5, special converter will be used.

2. finding where to process
    Then mdnconv looks for (part of) internationalized domain name in the converted line, and picks them up for further processing.
    mdnconv recognizes the character sequence having the following property as the internationalized domain name.

    •   containing at least one non-ASCII character, and

    •   consisting of legal domain name characters (alphabets, digits, hypens), non-ASCII characters and period.

    If you are not quite sure what this means (as I), the following regular expression may help you.
        [-A-Za-z0-9.]*<non-ASCII char>([-A-Za-z0-9.]|<non-ASCII char>)*
    For example, only ``www.###.com'' will be picked up from the following lines (`#' denotes non-ASCII character).
        www.###.com.    IN CNAME serv.xyz.com.
        serv.xyz.com.   IN A     10.0.0.1
    If -whole option is specified, this step is skipped and the entire line is subject to further processing.

3. normalization
    For each string picked up by the last step, normalization is performed. Multiple normalization schemes can be applied.

4. output-side conversion
    Finally, mdnconv converts the normalized strings from UTF-8 encoding to the output codeset, typically UTF-8, UTF-5 or RACE. And it writes them to stdout together with the rest of the line.

FILE MANAGEMENT
Maybe the best way to manage named.conf or zone master files that contains internationalized domain name is to keep them in your local codeset so that they can be edited with your favorite editor, and generate UTF-8 or UTF-5 (or whatever) version using mdnconv. `make' is a convenient tool for this purpose. Suppose the local codeset version has suffix `.lc', and its UTF-8 version has suffix `.utf8'. The following Makefile enables you to generate UTF-8 version from local codeset version by just typing `make'.
    .SUFFIXES: .lc .utf8
    .lc.utf8:
            mdnconv -in $(LOCALCODE) -out UTF-8 $(MDNCONVOPT) $< > $@
    LOCALCODE = EUC-JP
    MDNCONVOPT = -normalize unicode-form-c
    DESTFILES = db.zone1.utf8 db.zone2.utf8
    all: $(DESTFILES)

SEE ALSO
mdnres.conf(5), iconv(3) (if your system has one)

BUGS
The automatic input-code selection depends on your system, and sometimes it cannot guess or guess wrong. It is better to explicitly specify it using -in option.

ZLD handling has some problems. Especially automatic ZLD supply feature (-auto option) is inherently imperfect and you shouldn't rely on it.

Some mechanism is required to force normalization and output-side conversion on ASCII-only domain names.