public static byte getDirectionality(char ch)
Returns the Unicode directionality property for the given character. Character directionality is used to calculate the visual ordering of text. The directionality value of undefined char values is DIRECTIONALITY_UNDEFINED.
Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the getDirectionality(int) method.
public class CharacterGetDirectionality
public static void main(String args)
char ch1, ch2;
ch1 = 'M';
ch2 = '\u06ff';
byte b1, b2;
// assign directionality of ch1, ch2 to b1, b2
b1 = Character.getDirectionality(ch1);
b2 = Character.getDirectionality(ch2);
* byte value 0 represents DIRECTIONALITY_LEFT_TO_RIGHT
* byte value 2 represents DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC
String str1 = "Directionality of " + ch1 + " is " + b1;
String str2 = "Directionality of ch2 is " + b2;
System.out.println( str1 );
System.out.println( str2 );
Directionality of M is 0
Directionality of ch2 is 2
Character directionality is used to calculate the visual ordering of text. The directionality value of undefined char values is DIRECTIONALITY_UNDEFINED.
ch - char for which the directionality property is requested.
the directionality property of the char value.