Mercurial > cpython-lru_cache-weakref
diff Objects/unicodeobject.c @ 13624:83a595e691e4 legacy-trunk
- change \x to mean "byte" also in unicode literals
(patch #100912)
| author | Fredrik Lundh <fredrik@pythonware.com> |
|---|---|
| date | Sun, 16 Jul 2000 18:47:43 +0000 |
| parents | 167de4953812 |
| children | d6d23d5e296d |
line wrap: on
line diff
--- a/Objects/unicodeobject.c Sun Jul 16 17:10:50 2000 +0000 +++ b/Objects/unicodeobject.c Sun Jul 16 18:47:43 2000 +0000 @@ -1198,13 +1198,15 @@ *p++ = x; break; - /* \xXXXX escape with 0-4 hex digits */ + /* \xXXXX escape with 1-n hex digits. for compatibility + with 8-bit strings, this code ignores all but the last + two digits */ case 'x': x = 0; c = (unsigned char)*s; if (isxdigit(c)) { do { - x = (x<<4) & ~0xF; + x = (x<<4) & 0xF0; if ('0' <= c && c <= '9') x += c - '0'; else if ('a' <= c && c <= 'f') @@ -1213,7 +1215,7 @@ x += 10 + c - 'A'; c = (unsigned char)*++s; } while (isxdigit(c)); - *p++ = x; + *p++ = (unsigned char) x; } else { *p++ = '\\'; *p++ = (unsigned char)s[-1];
