private void checkForBadCharacters(String json) throws Exception
{
byte[] bytes = json.getBytes();
UniversalDetector ud = new UniversalDetector(null);
ud.handleData(bytes, 0, bytes.length);
ud.dataEnd();
String encoding = ud.getDetectedCharset();
if ( encoding != null )
{
//do an extra check for charcode 65533 if encoding is utf-8
if ( encoding.equals("UTF-8"))