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

  1. Ensure the input is decoded with the correct charset (Cp1252 for Windows-1252 files) before this conversion
  2. Only call processCp1252misc on characters in the \u0080–\u009F range; filter others first
  3. Avoid running the conversion twice on the same text
  4. 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

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


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:&amp;)");

  /** 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)