簡體   English   中英

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

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

我想知道輸入的字符串是否包含Unicode:0x1a值是否在java中。 我無法識別→和其他特殊字符的值。

因為字符“→”具有Unicode代碼點\→

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

作為替代方案,您可以用十六進制表示法編寫字符:

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