Vim,iconv + nr2char和iconv +“\ x ..”

时间:2010-02-21 22:27:45

标签: vim utf-8

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

输出«??»和

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

输出«< 80>»。为什么呢?

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

1 个答案:

答案 0 :(得分:2)

因为nr2char(0x80)会产生U+0080,等于"\xc2\x80"。并且"\x80"不是有效的utf-8字符串。