private static EscapeStrategy chooseStrategy(String encoding) {
    if ("UTF-8".equalsIgnoreCase(encoding) ||
        "UTF-16".equalsIgnoreCase(encoding)) {
      return UTFEscapeStrategy;
    }

    // Note issue #149: https://github.com/hunterhacker/jdom/issues/149
    // require locale for case conversion to avoid potential security issue.
    if (encoding.toUpperCase(Locale.ENGLISH).startsWith("ISO-8859-") ||
        "Latin1".equalsIgnoreCase(encoding)) {
      return Bits8EscapeStrategy;
    }

    if ("US-ASCII".equalsIgnoreCase(encoding) ||
        "ASCII".equalsIgnoreCase(encoding)) {
      return Bits7EscapeStrategy;
    }

    try {
      final CharsetEncoder cse = Charset.forName(encoding).newEncoder();
      return new DefaultCharsetEscapeStrategy(cse);
    }
    catch (Exception e) {
      // swallow that... and assume false.
    }
    return DEFAULT_ESCAPE_STRATEGY;
  }
private static EscapeStrategy chooseStrategy(String encoding)