每当我遇到Unicode时,都没有用.我在Linux上,我从Windows获得这些文件:
$file *
file1: UTF-8 Unicode text
file2: ISO-8859 text
file3: ISO-8859 text
Run Code Online (Sandbox Code Playgroud)
在我发现文件有不同的编码之前,没有任何工作.我希望让我的生活变得轻松,并将它们全部放在相同的格式中:
iconv -f UTF-8 -t ISO-8859 file1 > test
iconv: conversion to `ISO-8859' is not supported
Try `iconv --help' or `iconv --usage' for more information.
Run Code Online (Sandbox Code Playgroud)
我试图转换为ISO,因为那只有1次转换+当我在gedit中打开那些ISO文件时,德语字母"ü"显示得很好.好的,接下来尝试:
iconv -f ISO-8859 -t UTF-8 file2 > test
iconv: conversion from `ISO-8859' is not supported
Try `iconv --help' or `iconv --usage' for more information.
Run Code Online (Sandbox Code Playgroud)
但显然这不起作用.
ISO-8859-x(Latin-1)编码仅包含非常有限的字符,您应始终尝试将其编码为UTF-8以使生活更轻松。
而且utf-8(Unicode)是ISO 8859的超集,因此您无法将UTF-8转换为ISO 8859也就不会感到惊讶
看来命令file只是提供了非常有限的文件编码信息
您可以尝试猜测来自编码ISO-8859-1或ISO-8859-15的编码,还是来自2〜14的编码,如@hobbs的注释所建议
你可以得到的支持的编码iconv由iconv -l
如果生活让您不敢猜测真实的文件编码,那么这个愚蠢的脚本可能会帮助您:D