Raymond Toy pushed to branch master at cmucl / cmucl Commits: 19f274f0 by Raymond Toy at 2021-01-29T17:30:03-08:00 ldb prints out Unicode characters When printing out a base-char, only the low 8 bits of the code were used. But with Unicode support, we need to take all the bits and print them out. For control codes we use the form "#\^x". (Was #\C-x, which isn't a valid supported character form.) Ascii is printed as normal "#\a", and everything else use uses "#\u+<hex>". While we're at it, we also added special cases like #\Vt that are listed in https://cmucl.org/docs/cmu-user/html/Characters.html#Characters. With this, we can print out all unicode characters in a form that can be pasted back into lisp. - - - - - 832e116a by Raymond Toy at 2021-01-30T01:54:08+00:00 Merge branch 'issue-100-ldb-base-char-printing' into 'master' ldb prints out Unicode characters See merge request cmucl/cmucl!67 - - - - - 1 changed file: - src/lisp/print.c Changes: ===================================== src/lisp/print.c ===================================== @@ -212,12 +212,15 @@ static void brief_otherimm(lispobj obj) { int type, c, idx; - char buffer[10]; type = TypeOf(obj); switch (type) { case type_BaseChar: - c = (obj >> 8) & 0xff; + /* + * A base-char should only be 16 bits long now. But + * sometimes it uses all 24. So just grab all the bits. + */ + c = (obj >> 8) & 0xfffff; switch (c) { case '\0': printf("#\\Null"); @@ -228,20 +231,35 @@ brief_otherimm(lispobj obj) case '\b': printf("#\\Backspace"); break; + case '\11': + printf("#\\Tab"); + break; + case '\13': + printf("#\\Vt"); + break; + case '\15': + printf("#\\Return"); + break; + case '\33': + printf("#\\Escape"); + break; + case '\40': + printf("#\\Space"); + break; case '\177': printf("#\\Delete"); break; default: - strcpy(buffer, "#\\"); if (c >= 128) { - strcat(buffer, "m-"); - c -= 128; - } - if (c < 32) { - strcat(buffer, "c-"); - c += '@'; - } - printf("%s%c", buffer, c); + /* Just print out the code value */ + printf("#\\u+%04X", c); + } else if (c < 32) { + /* Print it out as a control character */ + printf("#\\^%c", c + '@'); + } else { + /* Plain ASCII character */ + printf("#\\%c", c); + } break; } break; View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/ef9fc1bced6dbad3b63213d... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/ef9fc1bced6dbad3b63213d... You're receiving this email because of your account on gitlab.common-lisp.net.