tags:

views:

53

answers:

1
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                                          
Modified by Gentoo-7.2.303 
A: 

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

ZyX