Mercurial > cpython-lru_cache-weakref
comparison Python/codecs.c @ 80218:e4aedd239e45
#16336: merge with 3.3.
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Sat, 03 Nov 2012 23:05:18 +0200 |
| parents | 13dd8199c112 8d5c147f030d |
| children | 3a86a3f1d89a |
comparison
equal
deleted
inserted
replaced
| 80215:a7ebc0db5c18 | 80218:e4aedd239e45 |
|---|---|
| 789 return NULL; | 789 return NULL; |
| 790 } | 790 } |
| 791 /* Try decoding a single surrogate character. If | 791 /* Try decoding a single surrogate character. If |
| 792 there are more, let the codec call us again. */ | 792 there are more, let the codec call us again. */ |
| 793 p += start; | 793 p += start; |
| 794 if (strlen(p) > 2 && | 794 if (PyBytes_GET_SIZE(object) - start >= 3 && |
| 795 ((p[0] & 0xf0) == 0xe0 || | 795 (p[0] & 0xf0) == 0xe0 && |
| 796 (p[1] & 0xc0) == 0x80 || | 796 (p[1] & 0xc0) == 0x80 && |
| 797 (p[2] & 0xc0) == 0x80)) { | 797 (p[2] & 0xc0) == 0x80) { |
| 798 /* it's a three-byte code */ | 798 /* it's a three-byte code */ |
| 799 ch = ((p[0] & 0x0f) << 12) + ((p[1] & 0x3f) << 6) + (p[2] & 0x3f); | 799 ch = ((p[0] & 0x0f) << 12) + ((p[1] & 0x3f) << 6) + (p[2] & 0x3f); |
| 800 if (!Py_UNICODE_IS_SURROGATE(ch)) | 800 if (!Py_UNICODE_IS_SURROGATE(ch)) |
| 801 /* it's not a surrogate - fail */ | 801 /* it's not a surrogate - fail */ |
| 802 ch = 0; | 802 ch = 0; |
