Under terms of
MDEV-17088, a new tool mariadb-conv was implemented.
mariadb-conv is a character set conversion utility similar to iconv or uconv.
As of 10.5.1, mariadb-conv understands the following options:
f and -t understand MariaDB character sets names (same names as in SQL clauses CHARACTER SET or command line options like -default-character-set).
- This command converts the file file.latin1.txt from latin1 to utf8.
- This command converts the the file file.latin1.txt from latin1 to utf8, but now it reads the input data from stdin.
- This command uses mariadb-conv in a pipe:
By default, mariadb-conv exits whenever it encounters any conversion problems, e.g.:
- the input byte sequence is not valid in the source character set
- the character cannot be converted to the target character set
The option -c makes mariadb-conv ignore such errors and use the question mark '?' to replace bytes in bad input sequences, or unconvertable characters.
The option --delimiter=... makes mariadb-conv treat the specified characters as delimiters rather than the data to convert, so the input is treated as a combination of:
- data chunks, which are converted according to the -f and -t options
- delimiters, which are not converted and are copied from the input to the output as is.
As a side effect, mariadb-conv can be used to list MariaDB data directories in a human readable form.
Suppose you have created the following tables:
The above script makes the server create the following files in the MariaDB data directory:
It's not precisely clear which file store which table, because MariaDB uses a special table-name-to-file-name encoding.
This command on Linux (assuming an utf-8 console):
can print the table list in a readable way:
Note, the option --delimiter=".\n" is needed to make mariadb-conv treat the dot character (delimiting the encoded table name from the file extension) and the new line character (delimiting separate lines) as delimiters rather than as the data to convert (otherwise the conversion would fail).
Windows users can use the following command to list the data directory in the ANSI text console:
- the options -t assumes a Western machine
- the option -c is needed to ignore conversion errors for the Cyrillic and CJK characters
- --delimiter= additionally needs the carriage return character \r