diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-06-15 21:48:04 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-06-15 21:48:04 -0700 |
commit | 4a223e77f8bf67c9236232bce354d60951b25bed (patch) | |
tree | 9e9a1bb72884b56dfaa240763f979ca630cea23e /lib.c | |
parent | 548dd7697516a2fea8930d3fa9e88ea48d5ab630 (diff) | |
download | txr-4a223e77f8bf67c9236232bce354d60951b25bed.tar.gz txr-4a223e77f8bf67c9236232bce354d60951b25bed.tar.bz2 txr-4a223e77f8bf67c9236232bce354d60951b25bed.zip |
* lib.c (obj_print): Render character DC00 as "pnul".
Clean up code which chooses rendering for characters.
Print C0 and C1 control characters, as well as D800-DFFF,
FFFE and FFFF and characters above FFFF using hex;
others are printed using the #\<char> notation.
* parser.y (char_from_name): map "pnul" to DC00.
* txr.1: Documented pnul, clarified character
printing rules, and added a cautionary note about
possible ambiguity in printing.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -5754,11 +5754,16 @@ finish: case '\r': put_string(lit("return"), out); break; case 27: put_string(lit("esc"), out); break; case ' ': put_string(lit("space"), out); break; + case 0xDC00: put_string(lit("pnul"), out); break; default: - if (ch >= ' ') - put_char(chr(ch), out); - else + if ((ch < 0x20) || (ch >= 0x80 && ch < 0xA0)) format(out, lit("x~,02x"), num(ch), nao); + else if ((ch >= 0xD800 && ch < 0xE000) || ch == 0xFFFE || ch == 0xFFFF) + format(out, lit("x~,04x"), num(ch), nao); + else if (ch >= 0xFFFF) + format(out, lit("x~,06x"), num(ch), nao); + else + put_char(chr(ch), out); } } return obj; |