mdnconv
Overview
mdnconv is a code set (encoding) conversion tool for the named.conf configuration and zone master files used with name servers.
mdnconv receives the file specified by an argument or from standard input, executes the code set conversion and normalization specified by the option, and writes the result to standard output.
For detailed information about usage, refer to named.conf, Creating a Zone Master File in the User's Guide.
Startup
% mdnconv [Option...] [File...]
Option
- -in in-code
- Specifies the code set name in-code of input text.
The following code set names can be specified in in-code.
- Code set name accepted by iconv_open()
- UTF-5
- RACE
- BRACE
- LACE
- Alias of above code set names (refer to the -alias option)
When not specified, the default code set is obtained from the current locale.
- -out out-code
- Specifies the code set name out-code of output text.
Code set names that can be specified for out-code are the same as for in-code of the -in option.
When not specified, the code set specified in server encoding entry of the client configuration file is used. - -normalize scheme
- Specifies the normalization method. The following methods can be specified for scheme.
- ascii-uppercase
- ascii-lowercase
- unicode-uppercase
- unicode-lowercase
- unicode-form-c
- unicode-form-kc
- ja-kana-fullwidth
- ja-alnum-halfwidth
- ja-compose-voiced-sound
- ja-minus-hack
- ja-delimiter-hack
For individual normalization methods, refer to the normalizer module of the MDN library.
With this option, more than one method can be specified. When multiple methods are specified, normalization takes place in the order of the specification.
When this option is not specifed, the normalization method specified in normalization entry of the client configuration file is used.
- -zld ZLD
- Specifies ZLD. When the domain name to be converted is FQDN that ends with a period and also the last character matches with ZLD, the matched part will not be converted.
This processing is necessary so that the ZLD part is not converted in some ASCII-compatible encoding schemes such as UTF-5.
When this option is not specified, the value specified in the server ZLD entry of the client configuration file is used.
- -auto
- Used in combination with the -zld option.
When a domain name is converted that includes non-ASCII characters and ends with a period, ZLD specified by -zld option is automatically added after the period.
This reduces the need to explicitly write ZLD for zone master files, etc. However, because this is not a perfect complementary function, ZLD sometimes need to be explicitly written. In general, it is recommended that you do not rely on this function.
- -whole
- Normalization and conversion to the target code set are applied to the entire entered text. When this option is not specified, only the part where it is determined that the domain name includes non-ASCII characters is the subject of conversion. For details, see Details of Conversion Processing.
- -alias path
- Specifies the file path that defines the alias name of the code set name.
This file is a text file and in each line, one set of the alias name and formal name of the code set is written with one or more spaces as a delimiter. For example, the following examples Shift_JIS and EUC-JP define sjis and euc-jp as the alias.
# Lines that begin with a "#" are comments sjis Shift_JIS euc-jp EUC-JP
- -noconf
- The client configuration file is not loaded.
- -flush
- Flushes output for each line. When outputting to a pipe file, omdnconv usually writes data from a multiple number of lines in a single operation. By specifying this option, conversion result is written line by line. Usually, this option does not need to be specified but it may be useful when using mdnconv as a program to filter output from another program.
Details of Conversion Processing
The steps performed during conversion processing by mdnconv are described below.
- Loads a file or one line of text from standard input.
- Removes the carriage return at the end of the line. This prevents the carriage return from dissapearing; this is needed because when mdnconv is executed with the -whole option set, and also when the output encoding is ASCII-compatible encoding such as UTF-5 or RACE, the carriage code will also be encoded using UTF-5 or RACEencoding.
- Converts the line to UTF-8 encoding. The converter module of the MDN library is used for conversion.
Usually, the entire line is converted to UTF-8. However, when the input code set is "RACE", a prefix that identifies RACE encoding is used to extract the RACE encoded part for conversion to UTF-8.
- Checks whether or not the conversion result is correctly encoded as UTF-8.
The utf8 module of the MDN library is used for this operation.
Basically, this processing is not necessary but checking is performed at this point so that if there is a bug in code conversion implementation, it can be detected at an early stage.
- When the -whole option is specified, extraction of the processing target explained below is skipped and processing jumps to Step 7 because the entire line is the processing target.
- Multilingual domain name part is extracted from a line converted
to UTF-8.
The MDN selectiveencode module of the MDN library is used for this step.
The following partial text strings are extracted.
- 1Text that includes one or more non-ASCII characters
- Text that consists of only characters permitted for conventional domain names (alphabet, numbers, hyphens), non-ASCII characters, and periods.
Only the extracted part is the processing target for the subsequent normalization and other processing.
- Normalization is performed.
The normalizer module of the MDN library is used for this operation.
- In this operation, check whether the conversion result is
correctly encoded as UTF-8.
In essence, this processing is not necessary but checking is performed here in consideration of the possibility of bugs in normalization.
- When the normalized text string ends with a period and also matches the ZLD specified using -zld option, the ZLD part will not be included in the next code set conversion target. This method is used to prevent conversion of the ZLD part (to UTF-5, etc).
- Converts from UTF-8 encoding to the output encoding specified by -out. The converter module of the MDN library is used for this operation.
- When a text ends with a period prior to converting to the output encoding, and also the -auto option is specified, ZLD will be added after the text string.
- When the -whole option is specified, the converted text string is output in standard output.
When the -whole option is not specified, the converted text string and the part that was excluded from conversion in Step 6 above are merged and then output in standard output.
In both cases, the carriage return code is added at the end.
- The procedure ends when all input lines are processed. If not, the process returns to Step 1.