Java Character isLowSurrogate()方法

java.lang.Character.isLowSurrogate(char ch) 判断给定char值是Unicode低代理项代码单元(也称为尾部代理项代码单元)。

这样的值并不代表字符本身,而是在UTF-16编码的补充的字符表示被使用。

1 语法

public static boolean isLowSurrogate(char ch)

2 参数

ch:待测试的char值

3 返回值

如果char值在MIN_LOW_SURROGATE和MAX_LOW_SURROGATE(含)之间此方法返回true,否则返回false。

4 示例 

package com.yiidian;

/**
 * 一点教程网: http://www.yiidian.com
 */
/**
 * Java Character isLowSurrogate()方法
 */
import java.lang.*;

public class CharacterDemo {

   public static void main(String[] args) {

      // create 2 char primitives ch1, ch2
      char ch1, ch2;

      // assign values to ch1, ch2
      ch1 = 'udc28';
      ch2 = 'a';

      // create 2 boolean primitives b1, b2
      boolean b1, b2;

      /**
       *  check if ch1, ch2 are Unicode low-surrogate code units
       *  and assign results to b1, b2
       */
      b1 = Character.isLowSurrogate(ch1);
      b2 = Character.isLowSurrogate(ch2);

      String str1 = "ch1 is a Unicode low-surrogate is " + b1;
      String str2 = ch2 + " is a Unicode low-surrogate is " + b2;

      // print b1, b2 values
      System.out.println( str1 );
      System.out.println( str2 );
   }
}

输出结果为:

ch1 is a Unicode low-surrogate is true
a is a Unicode low-surrogate is false

 

热门文章

优秀文章