Java Program to determine a Character's Unicode Block


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

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 26-Jun-2020

247 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements