Character.UnicodeBlock.forName() Method

Advertisements


Description

The java.lang.Character.UnicodeBlock.forName() method returns the UnicodeBlock with the given name. Block names are determined by The Unicode Standard.This method accepts block names in the following forms:

  • Canonical block names as defined by the Unicode Standard. For example, the standard defines a "Basic Latin" block.

  • Canonical block names with all spaces removed. For example, "BasicLatin" is a valid block name for the "Basic Latin" block.

  • The text representation of each constant UnicodeBlock identifier. For example, this method will return the BASIC_LATIN block if provided with the "BASIC_LATIN" name.

Declaration

Following is the declaration for java.lang.Character.UnicodeBlock.forName() method

public static final Character.UnicodeBlock forName(String blockName)

Parameters

  • blockName -- This is a UnicodeBlock name.

Return Value

This method returns the UnicodeBlock instance identified by blockName.

Exception

  • IllegalArgumentException -- if blockName is an invalid name.

  • NullPointerException -- if blockName is null.

Example

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

package com.tutorialspoint;

import java.lang.*;

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
Advertisements