Reputation: 5967
As far as I know, the UTF-8 form of"你好" (means "How are you?" in English) is
\xe4\xbd\xa0\xe5\xa5\xbd
, and the UTF-16 form is u\u4f60\u597d
(or you can write it as \x4f\x60\x59\x7d
).
Now I use iconv to convert from UTF-8 to UTF-16. At first, I created a new file, with one line("你好") in it, named test, and I run the command:
cat test | iconv -f UTF-8 -t UNICODE
��`O}Y
It's not \x4f\x60\x59\x7d. How can I get the right output?
Upvotes: 2
Views: 4002
Reputation: 8197
It's not UTF-8
, but UCS-2
Try:-
cat test | iconv -f UCS-2 -t UTF-16
Upvotes: 2