code: public static void appendHexEscape(StringBuilder out, int codePoint) {
  
      if (Character.isSupplementaryCodePoint(codePoint)) {
        // Handle supplementary unicode values which are not representable in
        // javascript.  We deal with these by escaping them as two 4B sequences
        // so that they will round-trip properly when sent from java to javascript
        // and back.
        char[] surrogates = Character.toChars(codePoint);
        appendHexEscape(out, surrogates[0]);
        appendHexEscape(out, surrogates[1]);
  
      } else {
        out.append("\\u")
            .append(HEX_DIGITS[(codePoint >>> 12) & 0xF])
            .append(HEX_DIGITS[(codePoint >>> 8) & 0xF])
            .append(HEX_DIGITS[(codePoint >>> 4) & 0xF])
            .append(HEX_DIGITS[codePoint & 0xF]);
      }
    }
docs: Appends the Unicode hex escape sequence for the given code point (backslash + 'u' + 4 hex
  digits) to the given StringBuilder.
  
  <p>Note: May append 2 escape sequences (surrogate pair) in the case of a supplementary
  character (outside the Unicode BMP).
  
  <p>Adapted from StringUtil.appendHexJavaScriptRepresentation().
  
  @param out The StringBuilder to append to.
  @param codePoint The Unicode code point whose hex escape sequence to append.