{"record":{"id":"c603160063f09d54","repo":"stanfordnlp/CoreNLP","slug":"bad-process-cp1252","errorCode":null,"errorMessage":"Bad process cp1252","messagePattern":"Bad process cp1252","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"src/edu/stanford/nlp/process/LexerUtils.java","lineNumber":118,"sourceCode":"  }\n\n  /* CP1252: dagger, double dagger, per mille, bullet, small tilde, trademark */\n  public static String processCp1252misc(String arg) {\n    switch (arg) {\n    case \"\\u0086\":\n      return \"\\u2020\";\n    case \"\\u0087\":\n      return \"\\u2021\";\n    case \"\\u0089\":\n      return \"\\u2030\";\n    case \"\\u0095\":\n      return \"\\u2022\";\n    case \"\\u0098\":\n      return \"\\u02DC\";\n    case \"\\u0099\":\n      return \"\\u2122\";\n    default:\n      throw new IllegalArgumentException(\"Bad process cp1252\");\n    }\n  }\n\n  private static final Pattern AMP_PATTERN = Pattern.compile(\"(?i:&amp;)\");\n\n  /** Convert an XML-escaped ampersand back into an ampersand. */\n  public static String normalizeAmp(final String in) {\n    return AMP_PATTERN.matcher(in).replaceAll(\"&\");\n  }\n\n  /** This quotes a character with a backslash, but doesn't do it\n   *  if the character is already preceded by a backslash.\n   */\n  public static String escapeChar(String s, char c) {\n    int i = s.indexOf(c);\n    while (i != -1) {\n      if (i == 0 || s.charAt(i - 1) != '\\\\') {\n        s = s.substring(0, i) + '\\\\' + s.substring(i);","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/process/LexerUtils.java#L100-L136","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nchar mapped = LexerUtils.processCp1252misc(c); // throws for any unlisted char\n// after\nchar mapped = (c >= '\\u0080' && c <= '\\u009F') ? LexerUtils.processCp1252misc(c) : c;","handlingStrategy":"type-guard","validationCode":"if (c < '\\u0080' || c > '\\u009F') {\n  throw new IllegalArgumentException(\"Character not in cp1252 special range: U+\" + Integer.toHexString(c));\n}","typeGuard":"static boolean inCp1252SpecialRange(char c) {\n  return c >= '\\u0080' && c <= '\\u009F';\n}","tryCatchPattern":"try {\n  mapped = LexerUtils.processCp1252misc(c);\n} catch (IllegalArgumentException e) {\n  if (\"Bad process cp1252\".equals(e.getMessage())) {\n    mapped = c; // pass through characters outside the cp1252 misc range\n  } else throw e;\n}","preventionTips":["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"],"tags":["encoding","character-mapping","cp1252","illegal-argument","text-processing"],"backgroundTag":"invalid-argument-value","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}