3 ms·
If you're going to draw lines with characters, use the line drawing characters. We have Unicode now. I have a program which takes text files with ASCII line ar
by Animats 10y ago
If you're going to draw lines with characters, use the line drawing characters. We have Unicode now.
I have a program which takes text files with ASCII line art and automatically turns them into text files with UNICODE line art.[1] I wrote this for some very old documents, but it's still useful.
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Source Port ┃ Destination Port ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Sequence Number ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Acknowledgment Number ┃
┣━━━━━━━┳━━━━━━━━━━━┳━┳━┳━┳━┳━┳━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Data ┃ ┃U┃A┃P┃R┃S┃F┃ ┃
┃ Offset┃ Reserved ┃R┃C┃S┃S┃Y┃I┃ Window ┃
┃ ┃ ┃G┃K┃H┃T┃N┃N┃ ┃
┣━━━━━━━┻━━━━━━━━━━━┻━┻━┻━┻━┻━┻━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ Checksum ┃ Urgent Pointer ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┫
┃ Options ┃ Padding ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━┫
┃ data ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
[1] https://github.com/John-Nagle/pasv/blob/master/src/Util/picfix.py https://github.com/John-Nagle/pasv/blob/master/src/Util/picf...
- amelius 10y agoVery nice. Just one question: what if the host environment uses a large line height?
- userbinator 10y agoWe have Unicode now. Not everyone and not everywhere, and depending on the font, the line-drawing characters may not be the same width as the others even if it's a monospace font (e.g. see https://blog.helftone.com/ascii-art-unicode/ https://blog.helftone.com/ascii-art-unicode/ ). The whole point of text files in things like RFCs is to be as portable as possible, and using Unicode somewhat defeats that point.
- arcticbull 10y agoMy take-away from the Monodraw writeup was that Unicode is just as portable, and all Unicode line drawing glyphs are the same size in monospace fonts -- they're just not available in all fonts. When that happens, a different font may be substituted by browsers (probably not by Terminal, though). I wouldn't put the finger on Unicode but rather that not all fonts have all Unicode glyphs yet, as I seem to recall was the case with ASCII line drawing glyphs years back. Definitely seen that before and it's good to know why. Thanks!
- Animats 10y agoThat's a problem. The above example looks good in a Ubuntu terminal window and in Firefox, but misaligned in the "gedit" text editor. In the SciTE editor, the line drawing characters show as four hex values in a box. groff, even with the "preconv" preprocessor for Unicode, can't display them either. The box drawing characters aren't even in the astral planes. They're in plane 0 in the 0x2xxx range. So even old 16-bit Unicode implementations should support them. (The TCP header from an RFC was just an example. I'm converting some old troff documents to PDF, and they have lots of box drawings.)