Java Character lowSurrogate() 方法

2024 年 11 月 6 日 | 阅读 2 分钟

Character 类的 lowSurrogate(int codePoint) 方法返回用于在 UTF-16 编码中表示字符的尾部代理码单元。另一方面,如果指定的字符不是补充字符,则返回一个未指定的 char。

如果 isSupplementaryCodePoint(x) 方法为 true,则 isLowSurrogate(lowSurrogate(x)) 和 toCodePoint(highSurrogate(x), lowSurrogate(x))==x 方法也为 true。

语法

参数

上述方法只需要一个参数

a.) codePoint,即需要测试的字符。

返回值

lowSurrogate(int codePoint) 方法返回用作 UTF-16 编码中字符表示的尾部码单元。

示例 1

输出

The current surrogate code unit for the character65 is:?
The current surrogate code unit for the character152 is:?
The current surrogate code unit for the character567 is:?

示例 2

输出

The codePoint '49' is a current surrogate code unit.
The codePoint '121' is a current surrogate code unit.
The codePoint '2342' is a current surrogate code unit.