public static void encode(byte[] dst, int offset, String s) {
    final int length = s.length();
    for (int i = 0; i < length; i++) {
      char ch = s.charAt(i);
      if (ch != 0 && ch <= 127) { // U+0000 uses two bytes.
        dst[offset++] = (byte) ch;
      } else if (ch <= 2047) {
        dst[offset++] = (byte) (0xc0 | (0x1f & (ch >> 6)));
        dst[offset++] = (byte) (0x80 | (0x3f & ch));
      } else {
        dst[offset++] = (byte) (0xe0 | (0x0f & (ch >> 12)));
        dst[offset++] = (byte) (0x80 | (0x3f & (ch >> 6)));
        dst[offset++] = (byte) (0x80 | (0x3f & ch));
      }
    }
  }
Encodes the modified UTF-8 bytes corresponding to {@code s} into {@code dst}, starting at
{@code offset}.
android/android_framework/dex-maker/src/main/java/com/android/dex/Mutf8.java