code: private static String doEscape(byte[] valueBytes, int ri) {
          final byte[] escapedBytes = new byte[ri + (valueBytes.length - ri) * 3];
          // copy over the good bytes
          if (ri != 0) {
              System.arraycopy(valueBytes, 0, escapedBytes, 0, ri);
          }
          int wi = ri;
          for (; ri < valueBytes.length; ri++) {
              final byte b = valueBytes[ri];
              // Manually implement URL encoding, per the gRPC spec.
              if (isEscapingChar(b)) {
                  escapedBytes[wi] = '%';
                  escapedBytes[wi + 1] = HEX[(b >> 4) & 0xF];
                  escapedBytes[wi + 2] = HEX[b & 0xF];
                  wi += 3;
                  continue;
              }
              escapedBytes[wi++] = b;
          }
          final byte[] dest = new byte[wi];
          System.arraycopy(escapedBytes, 0, dest, 0, wi);
  
          return new String(dest, StandardCharsets.US_ASCII);
      }
docs: Escapes the given byte array.
  
  @param valueBytes the UTF-8 bytes
  @param ri The reader index, pointed at the first byte that needs escaping.