shiftJis static method
Minimal Shift-JIS handling: ASCII and half-width katakana map directly and double-byte sequences become the replacement character, so the rest of the payload still decodes instead of failing outright.
Implementation
static String shiftJis(Uint8List bytes) {
final StringBuffer buffer = StringBuffer();
for (int i = 0; i < bytes.length; i++) {
final int b = bytes[i];
if (b < 0x80) {
buffer.writeCharCode(b);
} else if (b >= 0xA1 && b <= 0xDF) {
buffer.writeCharCode(0xFF61 + (b - 0xA1));
} else {
buffer.write(String.fromCharCode(0xFFFD));
if (i + 1 < bytes.length) i++;
}
}
return buffer.toString();
}