archives

« Bugzilla Issues Index

#81 — Case of hex digits in evaluation of JSON.stringify("\u000E") isn't precisely specified


Per spec which is correct behavior?

assert(JSON.stringify("\u000E") === '"\\u000E"');
assert(JSON.stringify("\u000E") === '"\\u000e"');

The spec says this: "Let hex be the result of converting the numeric code unit value of C to a String of four hexadecimal digits." That seems to permit either -- but why do so? It's harder to test, and I can't think of a good reason why implementations could want to make different choices here.

Every browser I can test escapes to lowercase hex, so it seems best to require the produced hexadecimal digits to be lowercase.

I originally raised this on the es5-discuss list:

https://mail.mozilla.org/pipermail/es5-discuss/2011-March/003963.html

...receiving the response, "Unintentional under specification. You should file a bug at bugs.ecmascript.org":

https://mail.mozilla.org/pipermail/es5-discuss/2011-March/003964.html


Fixed in ES2015.