Encoding ascii8bit = context.runtime.getEncodingService().getAscii8bitEncoding();
if (readEncoding == null || (readEncoding == ascii8bit && writeEncoding == null)) { // No encoding conversion
// Leave for extra MRI bittwiddling which is missing from our IO
// Hack to initialize transcoder but do no transcoding
writeTranscoder = new CharsetTranscoder(context, ascii8bit, ascii8bit, transcodingActions);
} else {
Encoding fromEncoding = readEncoding;
Encoding toEncoding;
if (writeEncoding != null) {
toEncoding = writeEncoding;
} else {
fromEncoding = null;
toEncoding = readEncoding;
}
// If no write then default -> readEncoding
// If write then writeEncoding -> readEncoding
// If no read (see if above)
writeTranscoder = new CharsetTranscoder(context, toEncoding, fromEncoding, transcodingActions);
}
}