简体   繁体   English

如何制作一个包含 ascii 文本和 ascii 十六进制代码的混合常量字符串?

[英]How to make a mix constant string that has ascii text as well as ascii hex codes in it?

I want to define a constant string as following:我想定义一个常量字符串如下:
"Hello World$1F" “你好世界$1F”

Where the '$1F' is the ASCII hex code.其中“$1F”是 ASCII 十六进制代码。
Your help is highly appreciated.非常感谢您的帮助。

你要找的是:

"Hello World\u001F"

Java String, char, Character use the UTF-16 encoding of the Unicode character set. Java String、char、Character 使用 Unicode 字符集的 UTF-16 编码。 (Just in like JavaScript, .NET, VB4, NCHAR, NVARCHAR, ….) Any similarity to ASCII is rarely relevant. (就像 JavaScript、.NET、VB4、NCHAR、NVARCHAR,......)与 ASCII 的任何相似性很少相关。

So, by $1F you must mean the Unicode codepoint U+001F , which is represented in a String literal as the single UTF-16 code unit "\".因此,$1F 必须指 Unicode 代码点U+001F ,它在字符串文字中表示为单个 UTF-16 代码单元“\”。 (Note: You can visualize it using a control picture character ␟, too.) (注意:您也可以使用控制图片字符 ␟ 对其进行可视化。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM