code: private static boolean inEncoding(char high, char low, String encoding) {
          boolean isInEncoding;
          try {
              char cArray[] = new char[2];
              cArray[0] = high;
              cArray[1] = low;
              // Construct a String from the char 
              String s = new String(cArray);
              // Encode the String into a sequence of bytes 
              // using the given, named charset. 
              byte[] bArray = s.getBytes(encoding);
              isInEncoding = inEncoding(high,bArray);
          } catch (Exception e) {
              isInEncoding = false;
          }
          
          return isInEncoding;
      }
docs: This is heart of the code that determines if a given high/low
  surrogate pair forms a character that is in the given encoding.
  This method is probably expensive, and the answer should be cached.
  <p>
  This method is not a public API,
  and should only be used internally within the serializer.
  @param high the high char of
  a high/low surrogate pair.
  @param low the low char of a high/low surrogate pair.
  @param encoding the Java name of the encoding.
  
  @xsl.usage internal