gpt4 book ai didi

linux - 在 Linux 上在 UTF-8 和 ISO-8859 之间转换文件

转载 作者:IT王子 更新时间:2023-10-29 01:20:48 28 4
gpt4 key购买 nike

每次我遇到 Unicode 时,都无济于事。我在 Linux 上,我从 Windows 获得了这些文件:

$file *
file1: UTF-8 Unicode text
file2: ISO-8859 text
file3: ISO-8859 text

在我发现这些文件具有不同的编码之前,一切都不起作用。我想让我的生活更轻松,让它们都采用相同的格式:

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.

我尝试转换为 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.

但显然那是行不通的。

最佳答案

ISO-8859-x (Latin-1) 编码仅包含非常有限的字符,您应该始终尝试编码为 UTF-8 以使生活更轻松。

而 utf-8 (Unicode) 是 ISO 8859 的超集,因此您无法将 UTF-8 转换为 ISO 8859 也就不足为奇了

file 命令似乎只给出了非常有限的文件编码信息

您可以按照@hobbs 的评论中的建议,尝试从编码 ISO-8859-1 或 ISO-8859-15 或 2~14 中猜测另一个编码

并且您可以通过 iconv -l

获得支持的 iconv 编码

如果生活让您难以猜测真实的文件编码,this silly script might help you out :D

关于linux - 在 Linux 上在 UTF-8 和 ISO-8859 之间转换文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45465183/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com