Display \r and \t escape codes in string repr

pull/451/head
Andrew Scheller 2014-04-08 02:42:50 +01:00
rodzic 72d70cb045
commit 12968fb6b2
2 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -63,7 +63,10 @@ void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *e
print(env, "%c", *s);
} else if (*s == '\n') {
print(env, "\\n");
// TODO add more escape codes here if we want to match CPython
} else if (*s == '\r') {
print(env, "\\r");
} else if (*s == '\t') {
print(env, "\\t");
} else {
print(env, "\\x%02x", *s);
}

Wyświetl plik

@ -0,0 +1,3 @@
# anything above 0xa0 is printed as Unicode by CPython3.3
for c in range(0xa1):
print("0x%02x: %s" % (c, repr(chr(c))))