the java code below
JSONObject obj = new JSONObject();
try{
obj.put("alert","•é");
byte[] test = obj.toString().getBytes("UTF-8");
logger.info("bytes are"+ test);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
};
produces a JSONObject which escapes the bullet character, but not the latin letter e with grave, e.g ""\u2022é", the byte code is [123, 34, 97, 108, 101, 114, 116, 34, 58, 34, 92, 117, 50, 48, 50, 50, -61, -87, 34, 125]
How can get I the same exact output in Javascript (in terms of byte sequence)? I don't understand why JSONObject is only escaping one character but not the other. I don't know what rule it followed.
It seems in javascript I can only either escape everything other than the ASCII, (eg.\u007f-\uffff) or don't escape at all.
Thanks!
byte[]anyway? That's a different issue that the escaping shown.