How to determine if a char value is a Unicode surrogate code unit in Java

1 Answer

0 votes
package javaapplication1;
 
public class JavaApplication1 {
 
    public static void main(String[] args) {
 
        char ch = 'a';

        boolean b;
        
        b = Character.isSurrogate(ch);
        System.out.println(b);
        
        System.out.println(Character.isSurrogate('\ud800'));
    }
}
 
/*
run:

false
true
 
*/

 



answered Sep 16, 2016 by avibootz
...