try {
Charset charset = Charset.forName(charsetName);
TransferEncoding encoding = TransferEncoding.headerWordEncoding(encodingName);
byte[] encodedBytes = data.getBytes("US-ASCII");
ByteBuffer decodedBytes = encoding.decode(ByteBuffer.wrap(encodedBytes));
result.append(charset.decode(decodedBytes));
}
catch (Exception e) {
result.append(matcher.group());
}