Java Character isMirrored() 方法

2024年11月6日 | 阅读时长 5 分钟

Character 类的 isMirrored(char ch) 方法根据 Unicode 规范确定给定(或指定)的字符是否是镜像字符。镜像字符的字形必须水平镜像,以便在文本中从右到左显示。

注意:上述方法不能用于处理增补字符。为了处理增补字符,我们可以使用 isMirrored (int) 方法。

语法

参数

ch:需要测试镜像属性的字符。

返回值

isMirrored(char ch) 方法返回一个布尔值,即如果给定(或指定)的字符是镜像字符,则返回 true。否则,该方法返回 false。

示例 1

输出

Enter the first character:*
The first input '*' is not mirrored.
Enter the second character:[
The second input '[' is mirrored.

示例 2

输出

The first character '{' is a mirrored character: true
The second character '^' is a mirrored character: false
The third character '&' is a mirrored character: false

Java Character isMirrored () 方法

Character 类的 isMirrored(int codePoint) 方法根据 Unicode 规范确定给定(或指定)的字符是否是镜像字符。

镜像字符的字形必须水平镜像,以便在文本中从右到左显示。

语法

参数

codePoint:需要测试的字符的 codePoint。

返回值

isMirrored(int codePoint) 方法返回一个布尔值,即如果给定(或指定)的字符是镜像字符,则返回 true。否则,该方法返回 false。

示例 1

输出

The first Codepoint '93' is mirrored 
The second codepoint '121' is not mirrored. 
The third codepoint '168' is not mirrored. 
The fourth codepoint '199' is not mirrored.

示例 2

输出

The first codePoint '3073' represents a mirrored character: false
The second codePoint '60' represents a mirrored character: true
The third codePoint '120' represents a mirrored character: false

示例 3

输出

Enter the first input:[
The character '[' is mirrored. 
Enter the second input:*
The character '*' is not mirrored.
Enter the third input:}
The character '}' is not mirrored.