Java Character isISOControl() Method

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

Definition

In Java, Character.isISOControl(ch) returns true when the character is an ISO control character: a code from 0x00 to 0x1F or from 0x7F to 0x9F. These are invisible instructions, not printable characters, such as tab, newline, carriage return, bell (0x07), escape (0x1B), and delete (0x7F).

The rule is a fixed numeric range, so unlike most tests it does not depend on the Unicode version. The space (0x20) and the non-breaking space (0xA0) sit just outside the ranges and are not controls.

A static method of java.lang.Character (Java 1.1+): call it on the class, as in Character.isISOControl(...); 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.

Syntax

Pass a char or an int code point.

Java
Character.isISOControl('\n');       // true  (0x0A)
Character.isISOControl('\u001B');   // true  (escape)
Character.isISOControl(' ');        // false (0x20)
Character.isISOControl('\u0085');   // true  (0x85, next line)
CallWhat it does
Character.isISOControl(c)Is this an invisible control code?
if (!Character.isISOControl(c)) out.append(c);Strip control codes from text.
Character.isISOControl(c) && !Character.isWhitespace(c)Controls other than tab, newline, and friends.

Overloads: isISOControl(char ch) and isISOControl(int codePoint). Note the capital ISO in the name: isIsoControl does not compile.

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

Parameters

ParameterDescription
ch (char)The character to test.
codePoint (int)The code point to test.

Return Value

Return ValueDescription
trueThe value is in 0x00 to 0x1F or 0x7F to 0x9F.
falseAny other value.

Compare with Similar Methods

Related character groups:

MethodHow it differs
isWhitespace(ch)Overlaps for tab, newline, and similar; also includes the space.
isIdentifierIgnorable(ch)Non-whitespace controls plus FORMAT characters.
getType(ch)ISO controls report CONTROL (15).

Java Examples

Example 1 — Which Characters Are ISO Controls?

Test values at both ends of each range and just outside them.

Java
public class CharacterIsIsoControlTable {
    public static void main(String[] args) {
        char[] chars = {'\u0000', '\t', '\n', '\u001B', ' ', '~', '\u007F', '\u0085', '\u00A0'};
        for (char c : chars) {
            System.out.println((int) c + " control=" + Character.isISOControl(c));
        }
    }
}

How It Works

  1. The first range. NUL (0), tab (9), newline (10), and escape (27) all lie between 0x00 and 0x1F.
  2. Printable ASCII in between. The space (32) and the tilde (126) are ordinary characters.
  3. The second range. DELETE (127) and NEXT LINE (133) fall between 0x7F and 0x9F; the non-breaking space (160) is just past the end.

Example 2 — Strip Terminal Control Codes from a Log Line

A log line contains a bell character and an escape code. Remove the control characters and count them.

Java
public class CharacterIsIsoControlStrip {
    public static void main(String[] args) {
        String line = "OK\u0007 done\u001B[0m";
        StringBuilder clean = new StringBuilder();
        int removed = 0;
        for (char c : line.toCharArray()) {
            if (Character.isISOControl(c)) {
                removed++;
            } else {
                clean.append(c);
            }
        }
        System.out.println(clean + " (removed " + removed + ")");
    }
}

How It Works

  1. Two hidden controls. U+0007 is BELL and U+001B is ESCAPE, which starts terminal colour codes such as ESC[0m.
  2. Only the controls go. Both fail the else branch and are counted; every printable character, including the space, is copied.
  3. Leftovers. The text [0m stays, because only the escape character itself is a control; removing full colour codes needs extra parsing.

Example 3 — Print Control Characters as Visible Escapes

Turn every control character into a \uXXXX-style text escape so that a log line shows exactly what the string contains.

Java
public class CharacterIsIsoControlEscape {
    public static void main(String[] args) {
        String s = "A\tB\u0000C";
        StringBuilder out = new StringBuilder();
        for (char c : s.toCharArray()) {
            if (Character.isISOControl(c)) {
                String hex = Integer.toHexString(c);
                while (hex.length() < 4) {
                    hex = "0" + hex;
                }
                out.append("\\u").append(hex);
            } else {
                out.append(c);
            }
        }
        System.out.println(out);
    }
}

How It Works

  1. Hex with padding. Integer.toHexString gives "9" for the tab and "0" for NUL; the while loop pads both to four digits.
  2. A literal backslash. "\\u" in the source is a backslash followed by u. The doubled backslash keeps the compiler from reading it as a Unicode escape.
  3. Printable text untouched. A, B, and C are not controls, so they are appended as they are.

Frequently Asked Questions

Exactly U+0000 to U+001F and U+007F to U+009F, which are 65 characters in total.
No. The space is U+0020, just after the first control range.
Yes. Tab (U+0009), newline (U+000A), and carriage return (U+000D) are ISO controls, and they are also whitespace.
No. It is defined by two fixed numeric ranges, so it gives the same answer on every JDK.
Skip a character only when isISOControl(c) && !Character.isWhitespace(c). That keeps tab, newline, and carriage return.

Next: isJavaIdentifierPart()

Check whether a character may appear after the first character of a Java identifier.

isJavaIdentifierPart() 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.

13 people found this page helpful