Scala Char isSurrogate() 方法与示例
isSurrogate()方法用于查找指定的 char 值是否为 Unicode 代理代码单元。这些值本身并不表示字符,而是用于表示 UTF-16 编码中的补充字符。
Method Definition: def isSurrogate: Boolean
Return Type: It returns true if the stated character is surrogate else it returns false.
示例:1#
// Scala program of isSurrogate()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isSurrogate() method
val result = ('\ud8b4').isSurrogate
// Displays output
println(result)
}
}
输出:
true
示例:2#
// Scala program of isSurrogate()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isSurrogate() method
val result = ('\u0555').isSurrogate
// Displays output
println(result)
}
}
输出:
false