Skip to content

illegal-escape-text

Javastyleno fixdefault: offjava/google

Reports a string or character literal that writes a backspace, tab, line feed, form feed, carriage return, quote or backslash as an octal or unicode escape (\u0009).

These characters have their own escapes (\b, \t, \n, \f, \r, \", \', \\) which every reader knows. A unicode escape for a line feed is even translated before the lexer runs, so \u000a in a string ends the line and does not compile.

To fix, use the special escape.

Reported
class A {
String a = "\u0009";
String b = "\011";
String c = "\t\u0041";
char d = '\u0027';
String e = "\134";
}
java:
lint:
rules:
illegal-escape-text: warn # off (default), warn, error

Enabled by the presets: java/google.

Suppress one line with sudsy-disable-next-line illegal-escape-text in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
checkstyle IllegalTokenText partial Only the special-escape message of the Google config.