0

我正在使用 Ubuntu。我的控制台(使用 Python 或 bash)不打印 4 个字节的 utf8 字符,仅打印 3 个字节或更少。

示例(bash):

eran@eran-MS-7788:~/Dropbox/help$ echo -e "\xee\x8c\xb0"
# This prints the v sign
eran@eran-MS-7788:~/Dropbox/help$ echo -e "\xf0\x9f\x8f\x80"
# This should print the basketball sign but does not print so

我从 Python 控制台得到了同样的结果。

有什么办法可以解决这个问题?

4

1 回答 1

0

Most so called Unicode fonts only implement characters present in Unicode BMP (Basic Multiligual Plane) - from U+0000 to U+FFFF, which all can be represented using just 3 bytes using UTF-8.

There are very few fonts that implement characters beyond BMP: that is, from U+010000 to U+1FFFFF (which are encoded using 4 bytes in UTF-8), and I would think that your Linux console or terminal is no exception. Because of this, you are not likely to see character you expect. Over time, it is possible that support for characters beyond BMP would become better, but it will probably take a long time. You can read more about this here.

于 2013-07-15T06:53:44.660 回答