// We have to escape the backslashes below.
if (c == '\\") out.write("\\u005C");
else if (c < 128) out.write(c);
else {
String s = Integer.toHexString(c);
// Pad with leading zeroes if necessary.
if (c < 256) s = "00" + s;
else if (c < 4096) s = "0" + s;
out.write("\\u");
out.write(s);
}