### Question:
Utf8 { @SuppressWarnings({ "squid:S3776", "squid:S135" }) public static int decode(final byte[] sa, final int from, final int len, final char[] da) { final int end = from + len; int count = 0; int pos = from; while (pos < end) { int b1 = sa[pos++]; if (b1 >= 0) { da[count++] = (char) b1; continue; } else if ((b1 >> 5) == -2 && pos < end) { int b2 = sa[pos++]; if ((b1 & 0x1e) != 0x0 && (b2 & 0xc0) == 0x80) { da[count++] = (char) (((b1 << 6) ^ b2) ^ ((0xFFFFFFC0 << 6) ^ 0xFFFFFF80)); continue; } pos--; } else if ((b1 >> 4) == -2 && pos + 1 < end) { int b2 = sa[pos++]; int b3 = sa[pos++]; if ((b1 != (byte) 0xe0 || (b2 & 0xe0) != 0x80) && (b2 & 0xc0) == 0x80 && (b3 & 0xc0) == 0x80) { da[count++] = (char) ((b1 << 12) ^ (b2 << 6) ^ (b3 ^ ((0xFFFFFFE0 << 12) ^ (0xFFFFFF80 << 6) ^ 0xFFFFFF80))); continue; } pos -= 2; } else if ((b1 >> 3) == -2 && pos + 2 < end) { int uc = (b1 << 18) ^ (sa[pos++] << 12) ^ (sa[pos++] << 6) ^ (sa[pos++] ^ ((0xFFFFFFF0 << 18) ^ (0xFFFFFF80 << 12) ^ (0xFFFFFF80 << 6) ^ 0xFFFFFF80)); if (Character.isSupplementaryCodePoint(uc)) { da[count++] = (char) ((uc >>> 10) + (Character.MIN_HIGH_SURROGATE - (Character.MIN_SUPPLEMENTARY_CODE_POINT >>> 10))); da[count++] = (char) ((uc & 0x3ff) + Character.MIN_LOW_SURROGATE); continue; } pos -= 3; } da[count++] = '\uFFFD'; } return count; }  @SuppressWarnings({ "squid:S3776", // Cognitive Complexity of methods should not be too high "squid:S135" // Loops should not contain more than a single "break" or "continue" statement }) static int decode(final byte[] sa, final int from, final int len, final char[] da); @SuppressWarnings({ "squid:S135" // Loops should not contain more than a single "break" or "continue" statement }) static int encode(final byte[] da, final char[] sa, final int from, final int to); static final int MAX_BYTES_PER_CHAR; }### Answer:
@Test void testDecode() { assertTrue(matchDecode("")); assertTrue(matchDecode("1234567890Az")); assertTrue(matchDecode("中文")); assertTrue(matchDecode("┯┰┱╂╁┾")); assertTrue(matchDecode("ⅠⅡⅢⅣ㈣㈢⒈⒐⑽")); assertTrue(matchDecode("\u0080\u00CA\u01CA\u07FF")); assertTrue(matchDecode("\uD856\uDC65\uD866\uDC66")); assertTrue(matchDecode("\uD700\uE000")); }