Java - Character isIdeographic() Method



The Java Character isIdeographic() method checks whether a code point is a CJKV ideographic character (defined by the Unicode standards) or not.

Before learning what an Ideograph means in a Unicode system, let us understand its general meaning −

An ideograph, in general, is defined as a symbol that represents an idea. For example, emojis are considered ideographs as describe various emotions with just symbols. However, in Unicode, ideographs are used to describe the idea of various Chinese, Japanese, Korean and Vietnamese characters.

Few characters in the CJK languages all originate from the han script, therefore, Unicode system specified a Unicode Block consisting all these unified ideographs.

Syntax

Following is the syntax of the Java Character isIdeographic() method.

public static boolean isIdeographic(int codePoint)

Parameters

  • codePoint − A Unicode code point value that is to be tested.

Return Value

The return value of this method will be true if the code point represents an Ideographic character, false otherwise.

Checking If a char is an Ideographic Example

The following example shows the usage of Java Character isIdeographic() method. In this example, we've created an int variable and assigned it a unicode value and using isIdeographic() method, we're checking if the given value represents a CJKV ideographic character or not.

package com.tutorialspoint;

public class isIdeographicDemo {
   public static void main(String args[]) {      
      int cp;
      Boolean b;
      cp = 0x9fcc;
      b = Character.isIdeographic(cp);
      System.out.println("The given code point is ideographic: " + b);
   }
}

Output

If we compile and run the given program, the output is produced as follows −

The given code point is ideographic: true

Checking If a char is an Ideographic Example

The following example shows the usage of Java Character isIdeographic() method. In this example, we've created an int variable and assigned it a unicode value and using isIdeographic() method, we're checking if the given value represents a CJKV ideographic character or not.

As the given argument is not an ideographic code point, the method returns false.

package com.tutorialspoint;

public class isIdeographicDemo {
   public static void main(String args[]) {      
      int cp;
      Boolean b;
      cp = 0x3000;
      b = Character.isIdeographic(cp);
      System.out.println("The given code point is ideographic: " + b);
   }
}

Output

The output for the program above is given as follows −

The given code point is ideographic: false

Checking If a char is an Ideographic Example

Since the method returns Boolean type values, conditional statements can be applied to check whether the given argument is an ideographic character or not.

package com.tutorialspoint;

public class isIdeographicDemo {
   public static void main(String args[]) {      
      int cp;
      Boolean b;
      cp = 0x62ff;
      b = Character.isIdeographic(cp);
      if(b)
         System.out.println("The given code point is an ideographic");
      else
         System.out.println("The given code point is not an ideographic");
   }
}

Output

On executing the given program, the output is obtained as follows −

The given code point is an ideographic
java_lang_character.htm
Advertisements