gpt4 book ai didi

图标:EILSEQ 带有 ASCII//IGNORE 但不带有 ASCII//TRANSLIT//IGNORE

转载 作者:行者123 更新时间:2023-12-01 05:34:57 26 4
gpt4 key购买 nike

将 iconv 与 //TRANSLIT//IGNORE 一起使用从 utf8 转换为 ascii 工作正常;它根据当前语言环境(在我的情况下为 de_DE)将不可转换的字符替换为正确的音译:

> echo 'möp' | iconv -f 'UTF8' -t 'ASCII//TRANSLIT//IGNORE'
moep

但是,当仅使用 //IGNORE 时没有 //TRANSLIT ,它抛出一个错误:
> echo 'möp' | iconv -f 'UTF8' -t 'ASCII//IGNORE'
mp
iconv: illegal input sequence at position 5

我想知道为什么会这样。输入序列完全一样,不应该 //IGNORE只是跳过无效字符?
使用 iconv C api 时,我收到 EILSEQ 错误 - 所以基本上我不知道输入字符串是否包含无效的 UTF8 ......

最佳答案

linux 上 iconv(1) 的手册页说明如下:

  -t to-encoding, --to-code=to-encoding
Use to-encoding for output characters.

If the string //IGNORE is appended to to-encoding, characters
that cannot be converted are discarded and an error is printed
after conversion.


它确实跳过了字符,但最后也会引发错误。

似乎通过使用//IGNORE 你真的无法区分输入和不可转换字符中包含无效字符的情况。换句话说,EILSEQ 和 EINVAL 情况的处理方式相同。

关于图标:EILSEQ 带有 ASCII//IGNORE 但不带有 ASCII//TRANSLIT//IGNORE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9249628/

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