Linux command
recode 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Convert a file from Latin-1 to UTF-8
recode latin1..utf8 [file]
Convert from UTF-8 to Latin-1
recode utf8..latin1 [file]
Convert HTML entities to UTF-8
recode html..utf8 [file]
Convert UTF-8 to HTML entities
recode utf8..html [file]
Convert file and save to new file
recode latin1..utf8 < [input] > [output]
List all available charsets
recode -l
Convert with verbose output
recode -v latin1..utf8 [file]
说明
recode converts text files between different character encodings and can also translate escape sequences. It supports over 300 charsets including ASCII, Latin series, UTF-8, UTF-16, and various national encodings. The conversion request uses the format source..destination where both parts specify charsets. Characters that cannot be represented in the destination charset are handled according to the mode (strict, force, or default lossy conversion). Beyond charset conversion, recode handles surface transformations like CRLF line endings, Base64, quoted-printable, HTML/XML entities, and various escape sequences. Multiple files can be processed, with each file converted in-place. Use shell redirection to preserve originals.
参数
- -l, --list
- List all known charsets and surfaces
- -f, --force
- Force conversion even if information loss may occur
- -s, --strict
- Strict mode; abort on untranslatable characters
- -d, --diacritics-only
- Convert only diacritics, leave other characters
- -c, --colstrings
- Enable column-oriented strings mode
- -g, --graphics
- Show graphical conversion summary
- -v, --verbose
- Verbose output showing conversion details
- -q, --quiet
- Suppress warnings and progress messages
- -h, --help
- Display help message
FAQ
What is the recode command used for?
recode converts text files between different character encodings and can also translate escape sequences. It supports over 300 charsets including ASCII, Latin series, UTF-8, UTF-16, and various national encodings. The conversion request uses the format source..destination where both parts specify charsets. Characters that cannot be represented in the destination charset are handled according to the mode (strict, force, or default lossy conversion). Beyond charset conversion, recode handles surface transformations like CRLF line endings, Base64, quoted-printable, HTML/XML entities, and various escape sequences. Multiple files can be processed, with each file converted in-place. Use shell redirection to preserve originals.
How do I run a basic recode example?
Run `recode latin1..utf8 [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -l, --list do in recode?
List all known charsets and surfaces