summaryrefslogtreecommitdiffstats
path: root/Modules/_json.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-14 00:13:11 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-14 00:13:11 (GMT)
commitf5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda (patch)
tree0eb7ea39ee5a60f384db53d5729b48d73986920d /Modules/_json.c
parente506437b52507609772e8141fdbb5ad2e17471bb (diff)
downloadcpython-f5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda.zip
cpython-f5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda.tar.gz
cpython-f5cff56a1be70d2c4e5cde5fa4e5d5d92e620dda.tar.bz2
Issue #13088: Add shared Py_hexdigits constant to format a number into base 16
Diffstat (limited to 'Modules/_json.c')
-rw-r--r--Modules/_json.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index dca3791..cafd5a9 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -175,18 +175,18 @@ ascii_escape_unichar(Py_UCS4 c, unsigned char *output, Py_ssize_t chars)
Py_UCS4 v = c - 0x10000;
c = 0xd800 | ((v >> 10) & 0x3ff);
output[chars++] = 'u';
- output[chars++] = "0123456789abcdef"[(c >> 12) & 0xf];
- output[chars++] = "0123456789abcdef"[(c >> 8) & 0xf];
- output[chars++] = "0123456789abcdef"[(c >> 4) & 0xf];
- output[chars++] = "0123456789abcdef"[(c ) & 0xf];
+ output[chars++] = Py_hexdigits[(c >> 12) & 0xf];
+ output[chars++] = Py_hexdigits[(c >> 8) & 0xf];
+ output[chars++] = Py_hexdigits[(c >> 4) & 0xf];
+ output[chars++] = Py_hexdigits[(c ) & 0xf];
c = 0xdc00 | (v & 0x3ff);
output[chars++] = '\\';
}
output[chars++] = 'u';
- output[chars++] = "0123456789abcdef"[(c >> 12) & 0xf];
- output[chars++] = "0123456789abcdef"[(c >> 8) & 0xf];
- output[chars++] = "0123456789abcdef"[(c >> 4) & 0xf];
- output[chars++] = "0123456789abcdef"[(c ) & 0xf];
+ output[chars++] = Py_hexdigits[(c >> 12) & 0xf];
+ output[chars++] = Py_hexdigits[(c >> 8) & 0xf];
+ output[chars++] = Py_hexdigits[(c >> 4) & 0xf];
+ output[chars++] = Py_hexdigits[(c ) & 0xf];
}
return chars;
}