Java Program to determine a Character's Unicode Block

Java 8Object Oriented ProgrammingProgramming

To determine a Character’s Unicode Block, use the Character.UnicodeBlock.of() method in Java. The method returns the object representing the Unicode block containing the given character, or null if the character is not a member of a defined block.

Let us see the syntax of Character.UnicodeBlock.of() method.

Character.UnicodeBlock of(char c)

Here, c is the character.

The following is an example that shows how we can represent the Unicode block containing the given character.

Example

 Live Demo

public class Demo {
   public static void main(String []args) {
      char ch = '\u5639';
      System.out.println(ch);
      Character.UnicodeBlock block = Character.UnicodeBlock.of(ch);
      System.out.println(block);
      System.out.println(Character.UnicodeBlock.of(' '));
      System.out.println(Character.UnicodeBlock.of('\u21ac'));
      System.out.println(Character.UnicodeBlock.of(1565));
   }
}

Output

嘹
CJK_UNIFIED_IDEOGRAPHS
BASIC_LATIN
ARROWS
ARABIC
raja
Published on 13-Nov-2018 10:28:44
Advertisements