Java Character isLowSurrogate() 方法

6 Nov 2024 | 3 分钟阅读

Character 类的 isLowSurrogate(char ch) 方法用于确定给定的(或指定的)字符是否为 Unicode 低代理码单元(也称为尾部代理码单元)。

这些值本身不代表字符,而是用于在 UTF-26 编码中表示补充字符。

语法

参数

ch:需要测试的字符。

返回值

isLowSurrogate(char ch) 方法返回一个布尔值,即如果给定的(或指定的)字符介于 MIN_LOW_SURROGATE 和 MAX_LOW_SURROGATE 之间,则返回 true。否则,该方法返回 false。

示例 1

输出

The first character '?' is a Unicode low-surrogate: true
The second character 'a' is a Unicode low-surrogate: false
The third character 'Y' is a Unicode low-surrogate: false

示例 2

输出

The first character '*'is a Unicode low-surrogate: false
The second character 'a' is a Unicode low-surrogate: false
The third character 'Y' is a Unicode low-surrogate: false
The fourth character '#' is a Unicode low-surrogate: false

示例 3

输出

Enter the first input:H
The character 'H' is not a low-surrogate.
Enter the second input:)
The character ')' is not a low-surrogate.
Enter the third input:6
The character '6' is not a low-surrogate..