in core/src/main/java/org/apache/james/mime4j/codec/DecoderUtil.java [264:304]
private static String tryDecodeEncodedWord(
final String mimeCharset,
final String encoding,
final String encodedText,
final DecodeMonitor monitor,
final Charset fallback,
final Map<Charset, Charset> charsetOverrides) {
Charset charset = lookupCharset(mimeCharset, fallback, charsetOverrides);
if (charset == null) {
monitor(monitor, mimeCharset, encoding, encodedText, "leaving word encoded",
"Mime charser '", mimeCharset, "' doesn't have a corresponding Java charset");
return null;
}
if (encodedText.length() == 0) {
monitor(monitor, mimeCharset, encoding, encodedText, "leaving word encoded",
"Missing encoded text in encoded word");
return null;
}
try {
if (encoding.equalsIgnoreCase("Q")) {
return DecoderUtil.decodeQ(encodedText, charset.name(), monitor);
} else if (encoding.equalsIgnoreCase("B")) {
return DecoderUtil.decodeB(encodedText, charset.name(), monitor);
} else {
monitor(monitor, mimeCharset, encoding, encodedText, "leaving word encoded",
"Warning: Unknown encoding in encoded word");
return null;
}
} catch (UnsupportedEncodingException e) {
// should not happen because of isDecodingSupported check above
monitor(monitor, mimeCharset, encoding, encodedText, "leaving word encoded",
"Unsupported encoding (", e.getMessage(), ") in encoded word");
return null;
} catch (RuntimeException e) {
monitor(monitor, mimeCharset, encoding, encodedText, "leaving word encoded",
"Could not decode (", e.getMessage(), ") encoded word");
return null;
}
}