你如何回应一个4位数的统一code在Bash的性格吗? [英] How do you echo a 4-digit Unicode character in Bash?

查看:144
本文介绍了你如何回应一个4位数的统一code在Bash的性格吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在UNI code骷髅添加到我的shell提示符(特别是'骷髅头'(U + 2620)),但我想不通的神奇咒语,使回波吐出,或任何其他4位统一code字符。两位数的人的很容易。例如,回声-e\\ X55。

I'd like to add the Unicode skull and crossbones to my shell prompt (specifically the 'SKULL AND CROSSBONES' (U+2620)), but I can't figure out the magic incantation to make echo spit it, or any other, 4-digit Unicode character. Two-digit one's are easy. For example, echo -e "\x55", .

在除它下面的答案应该指出的是,很明显,你的终端需要支持单向code的输出是你所期望的。 GNOME终端做了一个很好的工作,但它并不一定是默认打开。转到终端 - >设置字符编码,然后选择统一code(UTF-8)。

In addition to the answers below it should be noted that, obviously, your terminal needs to support Unicode for the output to be what you expect. gnome-terminal does a good job of this, but it isn't necessarily turned on by default. Go to Terminal-> Set Character Encoding and choose Unicode (UTF-8).

推荐答案

在UTF-8这实际上是6位数(或3个字节)。

In UTF-8 it's actually 6 digit (or 3 byte).

$ echo -e "\xE2\x98\xA0"
☠

: - )

要检查它是如何连接codeD由您的控制台,您可以使用hexdump都可以。

To check how it's encoded by your console, you can use hexdump.

echo -n ☠ | hexdump

这篇关于你如何回应一个4位数的统一code在Bash的性格吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆