How to get the unicode directionality property for the given character in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
 
    public static void main(String[] args) {
        
        char ch1, ch2;

        ch1 = 'W';
        ch2 = '\u06fd';

        byte b1, b2;

        b1 = Character.getDirectionality(ch1);
        System.out.println(b1); // 0 = DIRECTIONALITY_LEFT_TO_RIGHT
        
        b2 = Character.getDirectionality(ch2);
        System.out.println(b2); // 2 = DIRECTIONALITY_RIGHT_TO_LEFT
    }
}
 
/*
run:

0
2
 
*/

 



answered Sep 13, 2016 by avibootz
...