简体   繁体   English

如何检查输入的字符串是否包含Unicode:0x1a值

[英]How to check that entered string contains Unicode: 0x1a value

I want to know that entered string is contains Unicode:0x1a value or not in java. 我想知道输入的字符串是否包含Unicode:0x1a值是否在java中。 I am not able to identify the value of → and other special character. 我无法识别→和其他特殊字符的值。

Because the character "→" has a Unicode code point \→ . 因为字符“→”具有Unicode代码点\→

String s = "this is → my arrow";
if (s.contains("→")) {
  System.out.println("Contains arrow!");
} else {
  System.out.println("No arrows in my string :(");
}

As an alternative you may write the character in hex notation: 作为替代方案,您可以用十六进制表示法编写字符:

String s = "this is → my arrow";
if (s.contains("\u2192")) {
  System.out.println("Contains arrow!");
} else {
  System.out.println("No arrows in my string :(");
}

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

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