开发者

Vim, iconv+nr2char and iconv+"\x.."

开发者 https://www.devze.com 2022-12-20 16:58 出处:网络
echo strtrans(iconv(\"\\x80\", \"utf-8\", \"utf-32\")) Outputs «??» and echo strtrans(iconv(nr2char(0x80), \"utf-8\", \"utf-32\"))
echo strtrans(iconv(       "\x80", "utf-8", "utf-32"))

Outputs «??» and

echo strtrans(iconv(nr2char(0x80), "utf-8", "utf-32"))

outputs «<80>». Why?

(zyx:~) % LANG=C vim --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 12 2010 07:37:05)
Included patches: 1-303                            开发者_Python百科              
Modified by Gentoo-7.2.303 


Because nr2char(0x80) results in U+0080, which is equal to "\xc2\x80". And "\x80" is not a valid utf-8 string.

0

精彩评论

暂无评论...
验证码 换一张
取 消