diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2012-10-30 00:42:39 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2012-10-30 00:42:39 (GMT) |
commit | 76df43de30f40b5cc1de9d36a5a083dd8bd8cb27 (patch) | |
tree | be245b62c632a103851fa69d447e8d89e3ac782f /Modules/cjkcodecs | |
parent | a5e7cd06bb314f338eff3e2ef948ef35bed4487b (diff) | |
download | cpython-76df43de30f40b5cc1de9d36a5a083dd8bd8cb27.zip cpython-76df43de30f40b5cc1de9d36a5a083dd8bd8cb27.tar.gz cpython-76df43de30f40b5cc1de9d36a5a083dd8bd8cb27.tar.bz2 |
Issue #16330: Use surrogate-related macros
Patch written by Serhiy Storchaka.
Diffstat (limited to 'Modules/cjkcodecs')
-rw-r--r-- | Modules/cjkcodecs/cjkcodecs.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h index ab0682a..fb41bdd 100644 --- a/Modules/cjkcodecs/cjkcodecs.h +++ b/Modules/cjkcodecs/cjkcodecs.h @@ -148,8 +148,8 @@ static const struct dbcs_map *mapping_list; #if Py_UNICODE_SIZE == 2 # define WRITEUCS4(c) \ REQUIRE_OUTBUF(2) \ - (*outbuf)[0] = 0xd800 + (((c) - 0x10000) >> 10); \ - (*outbuf)[1] = 0xdc00 + (((c) - 0x10000) & 0x3ff); \ + (*outbuf)[0] = Py_UNICODE_HIGH_SURROGATE(c); \ + (*outbuf)[1] = Py_UNICODE_LOW_SURROGATE(c); \ NEXT_OUT(2) #else # define WRITEUCS4(c) \ @@ -188,11 +188,10 @@ static const struct dbcs_map *mapping_list; #if Py_UNICODE_SIZE == 2 #define DECODE_SURROGATE(c) \ - if (c >> 10 == 0xd800 >> 10) { /* high surrogate */ \ + if (Py_UNICODE_IS_HIGH_SURROGATE(c)) { \ REQUIRE_INBUF(2) \ - if (IN2 >> 10 == 0xdc00 >> 10) { /* low surrogate */ \ - c = 0x10000 + ((ucs4_t)(c - 0xd800) << 10) + \ - ((ucs4_t)(IN2) - 0xdc00); \ + if (Py_UNICODE_IS_LOW_SURROGATE(IN2)) { \ + c = Py_UNICODE_JOIN_SURROGATES(c, IN2) \ } \ } #define GET_INSIZE(c) ((c) > 0xffff ? 2 : 1) |