Java Character isUnicodeIdentifierPart() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
java.lang.Character

Definition

In Java, Character.isUnicodeIdentifierPart(ch) returns true when the character may appear after the first position of a Unicode identifier: letters, digits, connector punctuation such as '_', letter numbers, combining marks, non-spacing marks, and ignorable characters.

Compared with isJavaIdentifierPart(), the main difference is currency symbols: '$' is allowed in a Java name but not in a Unicode identifier.

A static method of java.lang.Character (Java 1.1+): call it on the class, as in Character.isUnicodeIdentifierPart(...); you do not need a Character object. No import is needed, because java.lang is always available. The int codePoint overload was added in Java 5.

Unicode version.

The answer comes from the Unicode Character Database built into your JDK, and each Java release follows a specific Unicode version (Java 8, for example, uses Unicode 6.2). The characters used on this page have had the same properties for many Unicode versions, so the examples print the same result on any current JDK.

Syntax

Pass a char, or an int code point.

Java
Character.isUnicodeIdentifierPart('7');      // true
Character.isUnicodeIdentifierPart('_');      // true
Character.isUnicodeIdentifierPart('$');      // false (isJavaIdentifierPart: true)
Character.isUnicodeIdentifierPart('\u0301'); // true, combining acute accent
CallWhat it does
Character.isUnicodeIdentifierPart(s.charAt(i))Is the char at i allowed inside the name?
Character.isUnicodeIdentifierPart(s.codePointAt(i))The same check by code point, safe for emoji and other supplementary chars.

Two overloads: isUnicodeIdentifierPart(char ch) since Java 1.1 and isUnicodeIdentifierPart(int codePoint) since Java 5.

Library declarations
Java
// java.lang.Character
public static boolean isUnicodeIdentifierPart(char ch)        // Java 1.1
public static boolean isUnicodeIdentifierPart(int codePoint)  // Java 5

Parameters

ParameterDescription
ch (char)The character to test.
codePoint (int)A Unicode code point; invalid values return false.

Return Value

Return ValueDescription
trueA letter, digit, connector, letter number, combining or non-spacing mark, or an ignorable character.
falseCurrency symbols, spaces, operators, most punctuation, emoji.

Compare with Similar Methods

Unicode rules vs Java rules:

MethodHow it differs
isJavaIdentifierPart(ch)Also allows currency symbols such as '$'.
isUnicodeIdentifierStart(ch)The stricter rule for the first character.
isLetterOrDigit(ch)Letters and digits only; '_' is false.

Java Examples

Example 1 — Inside an Identifier: Unicode and Java Rules

Test seven characters with both part methods.

Java
public class CharacterIsUnicodeIdentifierPartTable {
    static String show(char c) {
        return (c >= 32 && c < 127) ? "'" + c + "'" : "0x" + Integer.toHexString(c);
    }

    public static void main(String[] args) {
        char[] chars = {'a', '7', '_', '$', '-', '\u0301', '\u200B'};
        for (char c : chars) {
            System.out.println(show(c) + " unicode=" + Character.isUnicodeIdentifierPart(c)
                    + " java=" + Character.isJavaIdentifierPart(c));
        }
    }
}

How It Works

  1. Only one difference here. '$' is the single char in this list that Java accepts and Unicode rejects.
  2. Underscore is a part. Unlike at the start, '_' is allowed in later positions under both rules.
  3. Invisible but accepted. ZERO WIDTH SPACE (U+200B) is identifier-ignorable, so both methods return true.

Example 2 — Names That Are Valid in Java but Not Under Unicode Rules

Validate four names with both rule sets.

Java
public class CharacterIsUnicodeIdentifierPartNames {
    static boolean unicodeName(String s) {
        if (s.isEmpty() || !Character.isUnicodeIdentifierStart(s.charAt(0))) return false;
        for (int i = 1; i < s.length(); i++) {
            if (!Character.isUnicodeIdentifierPart(s.charAt(i))) return false;
        }
        return true;
    }

    static boolean javaName(String s) {
        if (s.isEmpty() || !Character.isJavaIdentifierStart(s.charAt(0))) return false;
        for (int i = 1; i < s.length(); i++) {
            if (!Character.isJavaIdentifierPart(s.charAt(i))) return false;
        }
        return true;
    }

    public static void main(String[] args) {
        String[] names = {"user_name", "user-name", "price$", "x2"};
        for (String n : names) {
            System.out.println(n + " unicode=" + unicodeName(n) + " java=" + javaName(n));
        }
    }
}

How It Works

  1. Two validators. Each helper checks the first char with a start method and the rest with the matching part method.
  2. The dollar sign. price$ is a legal Java variable name, but under Unicode rules '$' is not an identifier part.
  3. Common ground. Names built from letters, digits, and underscores after a letter, such as user_name and x2, pass both.

Example 3 — Validate a Name That Contains a Supplementary Letter

Walk the string by code point so a letter above U+FFFF is tested as one character.

Java
public class CharacterIsUnicodeIdentifierPartCodePoints {
    static boolean allParts(String s) {
        int i = 0;
        while (i < s.length()) {
            int cp = s.codePointAt(i);
            if (!Character.isUnicodeIdentifierPart(cp)) return false;
            i += Character.charCount(cp);
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println("with a math letter: " + allParts("a\uD835\uDC00_1"));
        System.out.println("with an emoji:      " + allParts("a\uD83D\uDE00"));
        System.out.println("lone char 0xd835:   " + Character.isUnicodeIdentifierPart('\uD835'));
    }
}

How It Works

  1. One code point at a time. codePointAt joins the pair 0xD835 0xDC00 into U+1D400, and charCount moves past both chars.
  2. The letter passes. U+1D400 is a letter, so the whole name is accepted; the emoji is a symbol, so the second name is not.
  3. Why code points matter. Testing the high surrogate 0xD835 by itself returns false, so a char-by-char scan would wrongly reject the first name.

Frequently Asked Questions

Letters, digits, connector punctuation such as _, letter numbers, combining and non-spacing marks, and identifier-ignorable characters.
The Unicode identifier rules do not include currency symbols. Java adds them as an extension, which isJavaIdentifierPart reflects.
Yes, after the first position. It is connector punctuation, which isUnicodeIdentifierPart accepts.
A supplementary letter is two chars, and each surrogate alone returns false. The int overload tests the whole character.
Yes. Identifier-ignorable chars such as U+200B pass, so strip them with isIdentifierIgnorable if names are compared as Strings.

Next: isUnicodeIdentifierStart()

Check whether a character may start an identifier under the Unicode rules.

isUnicodeIdentifierStart() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful