docs: public static String encodeHtmlEntities(String input, String encoding) {
  
          StringBuffer result = new StringBuffer(input.length() * 2);
          CharBuffer buffer = CharBuffer.wrap(input.toCharArray());
          Charset charset = Charset.forName(encoding);
          CharsetEncoder encoder = charset.newEncoder();
          for (int i = 0; i < buffer.length(); i++) {
              int c = buffer.get(i);
              if (c < 128) {
                  // first 128 chars are contained in almost every charset
                  result.append((char)c);
                  // this is intended as performance improvement since
                  // the canEncode() operation appears quite CPU heavy
              } else if (encoder.canEncode((char)c)) {
                  // encoder can encode this char
                  result.append((char)c);
              } else {
                  // append HTML entity reference
                  result.append(ENTITY_PREFIX);
                  result.append(c);
                  result.append(";");
              }
          }
          return result.toString();
      }