stanfordnlp/CoreNLP · warning · IllegalArgumentException
Bad process cp1252
Error message
Bad process cp1252
What it means
processCp1252misc maps Windows-1252 control-range characters (0x80–0x9F) to their Unicode equivalents via a switch; hitting the default branch means the input character is not one of the recognized cp1252 special characters. The method throws this IllegalArgumentException to flag unexpected input rather than silently passing it through.
Solutions
- Ensure the input is decoded with the correct charset (Cp1252 for Windows-1252 files) before this conversion
- Only call processCp1252misc on characters in the \u0080–\u009F range; filter others first
- Avoid running the conversion twice on the same text
- If you control the code, extend the switch or replace default-throw with returning the char unchanged for out-of-range input
Example fix
// before char mapped = LexerUtils.processCp1252misc(c); // throws for any unlisted char // after char mapped = (c >= '\u0080' && c <= '\u009F') ? LexerUtils.processCp1252misc(c) : c;
Defensive patterns
Strategy: type-guard
Validate before calling
if (c < '\u0080' || c > '\u009F') {
throw new IllegalArgumentException("Character not in cp1252 special range: U+" + Integer.toHexString(c));
} Type guard
static boolean inCp1252SpecialRange(char c) {
return c >= '\u0080' && c <= '\u009F';
} Try / catch
try {
mapped = LexerUtils.processCp1252misc(c);
} catch (IllegalArgumentException e) {
if ("Bad process cp1252".equals(e.getMessage())) {
mapped = c; // pass through characters outside the cp1252 misc range
} else throw e;
} Prevention
- Decode input with the correct charset (Cp1252 for Windows-1252 sources) before mapping
- Gate the call to characters in the \u0080–\u009F range only
- Avoid running cp1252 conversion twice on already-normalized UTF-8 text
When it happens
Trigger: Calling LexerUtils.processCp1252misc (directly or via the XML/lexer character pipeline) with a character outside the cp1252 0x80–0x9F special set, e.g. a stray "\u009F"-adjacent char, an already-converted character, or text processed twice.
Common situations: Applying cp1252 cleanup to text that is already UTF-8-normalized (double conversion); decoding files with the wrong charset so control chars appear that the map does not cover; custom pre-processing inserting characters outside the expected range.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Bad character encoding
- Cannot interpret
- Cannot interpret for
- Cannot open null document path!
- Cannot put a child trie with no keys
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/c603160063f09d54.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/process/LexerUtils.java:118
}
/* CP1252: dagger, double dagger, per mille, bullet, small tilde, trademark */
public static String processCp1252misc(String arg) {
switch (arg) {
case "\u0086":
return "\u2020";
case "\u0087":
return "\u2021";
case "\u0089":
return "\u2030";
case "\u0095":
return "\u2022";
case "\u0098":
return "\u02DC";
case "\u0099":
return "\u2122";
default:
throw new IllegalArgumentException("Bad process cp1252");
}
}
private static final Pattern AMP_PATTERN = Pattern.compile("(?i:&)");
/** Convert an XML-escaped ampersand back into an ampersand. */
public static String normalizeAmp(final String in) {
return AMP_PATTERN.matcher(in).replaceAll("&");
}
/** This quotes a character with a backslash, but doesn't do it
* if the character is already preceded by a backslash.
*/
public static String escapeChar(String s, char c) {
int i = s.indexOf(c);
while (i != -1) {
if (i == 0 || s.charAt(i - 1) != '\\') {
s = s.substring(0, i) + '\\' + s.substring(i);View on GitHub (pinned to 1b7edd19c4)