Java Character.UnicodeBlock Class



The Java Character.UnicodeBlock class is a family of character subsets representing the character blocks in the Unicode specification. Character blocks generally define characters used for a specific script or purpose.

Class Declaration

Following is the declaration for java.lang.Character.UnicodeBlock class −

public static final class Character.UnicodeBlock
   extends Character.Subset

Class Methods

Sr.No.

Method & Description

1

forName()

This method returns the UnicodeBlock with the given name.

2

of()

This 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.

2

of(int codePoint)

This 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.

Getting UnicodeBlock using Block Names Example

The following example shows the usage of Java Character.UnicodeBlock forName() method.

package com.tutorialspoint;

public class CharacterUnicodeBlockDemo {
  
   public static void main(String[] args) {
    
      // returns the UnicodeBlock instance with blockName "BASIC_LATIN"
      System.out.println(Character.UnicodeBlock.forName("BASIC_LATIN"));
  
      // returns the UnicodeBlock instance with blockName "BasicLatin"
      System.out.println(Character.UnicodeBlock.forName("BasicLatin"));

      // returns the UnicodeBlock instance with specified blockName 
      System.out.println(Character.UnicodeBlock.forName("ARABIC"));
      System.out.println(Character.UnicodeBlock.forName("MUSICALSYMBOLS"));
      System.out.println(Character.UnicodeBlock.forName("TAMIL"));
   }
}

Let us compile and run the above program, this will produce the following result −

BASIC_LATIN
BASIC_LATIN
ARABIC
MUSICAL_SYMBOLS
TAMIL
Advertisements