\x在Java中逃脱? [英] \x Escape in Java?
本文介绍了\x在Java中逃脱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道Java中是否存在类似于C ++中的类似hex(\x)转义。
例如:
I was wondering if there is a similar hex (\x) escape in Java like there is in C++. For example:
char helloworld[] = "\x48\x45\x4C\x4C\x4F\x20\x57\x47\x52\x4C\x44";
printf("%s", helloworld);
到目前为止,Java中没有hex(\x)转义。有没有一个替代方法是一样容易使用,而不必将一堆十六进制数字连接在一起?
There is no hex (\x) escape in Java from what it appears so far. Is there an alternative that is just as easy to use without having to concat a bunch of hex numbers together?
推荐答案
Java中的字符串始终以UTF-16编码,因此它使用Unicode转义: \\\H
。支持八进制字符: \110
Strings in Java are always encoded in UTF-16, so it uses a Unicode escape: \u0048
. Octal characters are supported as well: \110
这篇关于\x在Java中逃脱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文