private static boolean inEncoding(char ch,String encoding){
  boolean isInEncoding;
  try {
    char cArray[]=new char[1];
    cArray[0]=ch;
    String s=new String(cArray);
    byte[] bArray=s.getBytes(encoding);
    isInEncoding=inEncoding(ch,bArray);
  }
 catch (  Exception e) {
    isInEncoding=false;
    if (encoding == null)     isInEncoding=true;
  }
  return isInEncoding;
}

private static boolean inEncoding ( char ch , String encoding ) { boolean isInEncoding ; try { char cArray [ ] = new char [ 1 ] ; cArray [ 0 ] = ch ; String s = new String ( cArray ) ; byte [ ] bArray = s . getBytes ( encoding ) ; isInEncoding = inEncoding ( ch , bArray ) ; } catch ( Exception e ) { isInEncoding = false ; if ( encoding == null ) isInEncoding = true ; } return isInEncoding ; }
this is heart of the code that determines if a given character 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 .
