Box-drawing character

Midnight Commander using box-drawing characters in a terminal emulator

Box-drawing characters, also known as line-drawing characters, are a form of semigraphics widely used in text user interfaces to draw various geometric frames and boxes. Box-drawing characters typically only work well with monospaced fonts. In graphical user interfaces, these characters are much less useful as it is more simple and appropriate to draw lines and rectangles directly with graphical APIs. However, they are still useful for command-line interfaces and plaintext comments within source code.

Used along with box-drawing characters are block elements, shade characters, and terminal graphic characters. These can be used for filling regions of the screen and portraying drop shadows.

EncodingsEdit

UnicodeEdit

Unicode includes 128 such characters in the Box Drawing block.[1] In many Unicode fonts only the subset that is also available in the IBM PC character set (see below) will exist, due to it being defined as part of the WGL4 character set.

Unicode box-drawing symbols. A rendering showing all 128 symbols (as they should appear in the adjacent chart)
Box Drawing[1]
Official Unicode Consortium code chart (PDF)
  0 1 2 3 4 5 6 7 8 9 A B C D E F
U+250x โ”€ โ” โ”‚ โ”ƒ โ”„ โ”… โ”† โ”‡ โ”ˆ โ”‰ โ”Š โ”‹ โ”Œ โ” โ”Ž โ”
U+251x โ” โ”‘ โ”’ โ”“ โ”” โ”• โ”– โ”— โ”˜ โ”™ โ”š โ”› โ”œ โ” โ”ž โ”Ÿ
U+252x โ”  โ”ก โ”ข โ”ฃ โ”ค โ”ฅ โ”ฆ โ”ง โ”จ โ”ฉ โ”ช โ”ซ โ”ฌ โ”ญ โ”ฎ โ”ฏ
U+253x โ”ฐ โ”ฑ โ”ฒ โ”ณ โ”ด โ”ต โ”ถ โ”ท โ”ธ โ”น โ”บ โ”ป โ”ผ โ”ฝ โ”พ โ”ฟ
U+254x โ•€ โ• โ•‚ โ•ƒ โ•„ โ•… โ•† โ•‡ โ•ˆ โ•‰ โ•Š โ•‹ โ•Œ โ• โ•Ž โ•
U+255x โ• โ•‘ โ•’ โ•“ โ•” โ•• โ•– โ•— โ•˜ โ•™ โ•š โ•› โ•œ โ• โ•ž โ•Ÿ
U+256x โ•  โ•ก โ•ข โ•ฃ โ•ค โ•ฅ โ•ฆ โ•ง โ•จ โ•ฉ โ•ช โ•ซ โ•ฌ โ•ญ โ•ฎ โ•ฏ
U+257x โ•ฐ โ•ฑ โ•ฒ โ•ณ โ•ด โ•ต โ•ถ โ•ท โ•ธ โ•น โ•บ โ•ป โ•ผ โ•ฝ โ•พ โ•ฟ
Notes
1.^ As of Unicode version 13.0

The Block Elements Unicode block includes shading characters. 32 characters are included in the block.

Block Elements[1]
Official Unicode Consortium code chart (PDF)
  0 1 2 3 4 5 6 7 8 9 A B C D E F
U+258x โ–€ โ– โ–‚ โ–ƒ โ–„ โ–… โ–† โ–‡ โ–ˆ โ–‰ โ–Š โ–‹ โ–Œ โ– โ–Ž โ–
U+259x โ– โ–‘ โ–’ โ–“ โ–” โ–• โ–– โ–— โ–˜ โ–™ โ–š โ–› โ–œ โ– โ–ž โ–Ÿ
Notes
1.^ As of Unicode version 13.0

In version 13.0, Unicode was extended with another block containing many box-drawing characters, Symbols for Legacy Computing, which includes box-drawing characters and other symbols used by obsolete operating systems (mostly from the 1980s):

Symbols for Legacy Computing[1][2]
Official Unicode Consortium code chart (PDF)
  0 1 2 3 4 5 6 7 8 9 A B C D E F
U+1FB0x ๐Ÿฌ€ ๐Ÿฌ ๐Ÿฌ‚ ๐Ÿฌƒ ๐Ÿฌ„ ๐Ÿฌ… ๐Ÿฌ† ๐Ÿฌ‡ ๐Ÿฌˆ ๐Ÿฌ‰ ๐ŸฌŠ ๐Ÿฌ‹ ๐ŸฌŒ ๐Ÿฌ ๐ŸฌŽ ๐Ÿฌ
U+1FB1x ๐Ÿฌ ๐Ÿฌ‘ ๐Ÿฌ’ ๐Ÿฌ“ ๐Ÿฌ” ๐Ÿฌ• ๐Ÿฌ– ๐Ÿฌ— ๐Ÿฌ˜ ๐Ÿฌ™ ๐Ÿฌš ๐Ÿฌ› ๐Ÿฌœ ๐Ÿฌ ๐Ÿฌž ๐ŸฌŸ
U+1FB2x ๐Ÿฌ  ๐Ÿฌก ๐Ÿฌข ๐Ÿฌฃ ๐Ÿฌค ๐Ÿฌฅ ๐Ÿฌฆ ๐Ÿฌง ๐Ÿฌจ ๐Ÿฌฉ ๐Ÿฌช ๐Ÿฌซ ๐Ÿฌฌ ๐Ÿฌญ ๐Ÿฌฎ ๐Ÿฌฏ
U+1FB3x ๐Ÿฌฐ ๐Ÿฌฑ ๐Ÿฌฒ ๐Ÿฌณ ๐Ÿฌด ๐Ÿฌต ๐Ÿฌถ ๐Ÿฌท ๐Ÿฌธ ๐Ÿฌน ๐Ÿฌบ ๐Ÿฌป ๐Ÿฌผ ๐Ÿฌฝ ๐Ÿฌพ ๐Ÿฌฟ
U+1FB4x ๐Ÿญ€ ๐Ÿญ ๐Ÿญ‚ ๐Ÿญƒ ๐Ÿญ„ ๐Ÿญ… ๐Ÿญ† ๐Ÿญ‡ ๐Ÿญˆ ๐Ÿญ‰ ๐ŸญŠ ๐Ÿญ‹ ๐ŸญŒ ๐Ÿญ ๐ŸญŽ ๐Ÿญ
U+1FB5x ๐Ÿญ ๐Ÿญ‘ ๐Ÿญ’ ๐Ÿญ“ ๐Ÿญ” ๐Ÿญ• ๐Ÿญ– ๐Ÿญ— ๐Ÿญ˜ ๐Ÿญ™ ๐Ÿญš ๐Ÿญ› ๐Ÿญœ ๐Ÿญ ๐Ÿญž ๐ŸญŸ
U+1FB6x ๐Ÿญ  ๐Ÿญก ๐Ÿญข ๐Ÿญฃ ๐Ÿญค ๐Ÿญฅ ๐Ÿญฆ ๐Ÿญง ๐Ÿญจ ๐Ÿญฉ ๐Ÿญช ๐Ÿญซ ๐Ÿญฌ ๐Ÿญญ ๐Ÿญฎ ๐Ÿญฏ
U+1FB7x ๐Ÿญฐ ๐Ÿญฑ ๐Ÿญฒ ๐Ÿญณ ๐Ÿญด ๐Ÿญต ๐Ÿญถ ๐Ÿญท ๐Ÿญธ ๐Ÿญน ๐Ÿญบ ๐Ÿญป ๐Ÿญผ ๐Ÿญฝ ๐Ÿญพ ๐Ÿญฟ
U+1FB8x ๐Ÿฎ€ ๐Ÿฎ ๐Ÿฎ‚ ๐Ÿฎƒ ๐Ÿฎ„ ๐Ÿฎ… ๐Ÿฎ† ๐Ÿฎ‡ ๐Ÿฎˆ ๐Ÿฎ‰ ๐ŸฎŠ ๐Ÿฎ‹ ๐ŸฎŒ ๐Ÿฎ ๐ŸฎŽ ๐Ÿฎ
U+1FB9x ๐Ÿฎ ๐Ÿฎ‘ ๐Ÿฎ’ ๐Ÿฎ” ๐Ÿฎ• ๐Ÿฎ– ๐Ÿฎ— ๐Ÿฎ˜ ๐Ÿฎ™ ๐Ÿฎš ๐Ÿฎ› ๐Ÿฎœ ๐Ÿฎ ๐Ÿฎž ๐ŸฎŸ
U+1FBAx ๐Ÿฎ  ๐Ÿฎก ๐Ÿฎข ๐Ÿฎฃ ๐Ÿฎค ๐Ÿฎฅ ๐Ÿฎฆ ๐Ÿฎง ๐Ÿฎจ ๐Ÿฎฉ ๐Ÿฎช ๐Ÿฎซ ๐Ÿฎฌ ๐Ÿฎญ ๐Ÿฎฎ ๐Ÿฎฏ
U+1FBBx ๐Ÿฎฐ ๐Ÿฎฑ ๐Ÿฎฒ ๐Ÿฎณ ๐Ÿฎด ๐Ÿฎต ๐Ÿฎถ ๐Ÿฎท ๐Ÿฎธ ๐Ÿฎน ๐Ÿฎบ ๐Ÿฎป ๐Ÿฎผ ๐Ÿฎฝ ๐Ÿฎพ ๐Ÿฎฟ
U+1FBCx ๐Ÿฏ€ ๐Ÿฏ ๐Ÿฏ‚ ๐Ÿฏƒ ๐Ÿฏ„ ๐Ÿฏ… ๐Ÿฏ† ๐Ÿฏ‡ ๐Ÿฏˆ ๐Ÿฏ‰ ๐ŸฏŠ
U+1FBDx
U+1FBEx
U+1FBFx ๐Ÿฏฐ ๐Ÿฏฑ ๐Ÿฏฒ ๐Ÿฏณ ๐Ÿฏด ๐Ÿฏต ๐Ÿฏถ ๐Ÿฏท ๐Ÿฏธ ๐Ÿฏน
Notes
1.^ As of Unicode version 13.0
2.^ Grey areas indicate non-assigned code points

DOSEdit

The hardware code page of the original IBM PC supplied the following box-drawing characters, in what DOS now calls code page 437. This subset of the Unicode box-drawing characters is thus far more popular and likely to be rendered correctly:

0 1 2 3 4 5 6 7 8 9 A B C D E F
B โ”‚ โ”ค โ•ก โ•ข โ•– โ•• โ•ฃ โ•‘ โ•— โ• โ•œ โ•› โ”
C โ”” โ”ด โ”ฌ โ”œ โ”€ โ”ผ โ•ž โ•Ÿ โ•š โ•” โ•ฉ โ•ฆ โ•  โ• โ•ฌ โ•ง
D โ•จ โ•ค โ•ฅ โ•™ โ•˜ โ•’ โ•“ โ•ซ โ•ช โ”˜ โ”Œ

Their number is further limited to 22 on those code pages that replace the 18 "single/double hybrid" characters with other, usually alphabetic, characters (such as code page 850):

0 1 2 3 4 5 6 7 8 9 A B C D E F
B โ”‚ โ”ค โ•ฃ โ•‘ โ•— โ• โ”
C โ”” โ”ด โ”ฌ โ”œ โ”€ โ”ผ โ•š โ•” โ•ฉ โ•ฆ โ•  โ• โ•ฌ
D โ”˜ โ”Œ

Note: The non-double characters are the "thin" (light) ones (U+2500, U+2502), not the "bold" (heavy) ones (U+2501, U+2503).

Some OEM DOS computers supported other character sets, for example the Hewlett-Packard HP 110 / HP Portable and HP 110 Plus / HP Portable Plus, where in a modified version of the character set box-drawing characters were added in reserved areas of their normal HP Roman-8 character set.[2][3]

[2][3] 0 1 2 3 4 5 6 7 8 9 A B C D E F
8 โ• โ•— โ•” โ•š โ•ฃ โ•ฉ โ•ฆ โ•  โ• โ•‘ โ•ฌ
9 โ”˜ โ” โ”Œ โ”” โ”ค โ”ด โ”ฌ โ”œ โ”€ โ”‚ โ”ผ

Unix, CP/M, BBSEdit

On many Unix systems and early dial-up bulletin board systems the only common standard for box-drawing characters was the VT100 alternate character set (see also: DEC Special Graphics). The escape sequence Esc ( 0 switched the codes for lower-case ASCII letters to draw this set, and the sequence Esc ( B switched back:

0 1 2 3 4 5 6 7 8 9 A B C D E F
6 โ”˜ โ” โ”Œ โ”” โ”ผ
7 โ”€ โ”œ โ”ค โ”ด โ”ฌ โ”‚

A Bash script that displays all of the semigraphic characters:

$ for i in 6a 6b 6c 6d 6e 71 74 75 76 77 78; do printf "0x$i \x$i \x1b(0\x$i\x1b(B\n"; done

0x6a j โ”˜
0x6b k โ”
0x6c l โ”Œ
0x6d m โ””
0x6e n โ”ผ
0x71 q โ”€
0x74 t โ”œ
0x75 u โ”ค
0x76 v โ”ด
0x77 w โ”ฌ
0x78 x โ”‚

On some terminals, these characters are not available at all, and the complexity of the escape sequences discouraged their use, so often only ASCII characters that approximate box-drawing characters are used, such as - (hyphen-minus), | (vertical bar), _ (underscore), = (equal sign) and + (plus sign) in a kind of ASCII art fashion.

Modern Unix terminal emulators use Unicode and thus have access to the line-drawing characters listed above.

HistoricalEdit

Many microcomputers of the 1970s and 1980s had their own proprietary character sets, which also included box-drawing characters. Some of these sets, such as Commodore's PETSCII, include box-drawing symbols with no corresponding Unicode character.

The Sinclair ZX80, ZX81 and Spectrum included a set of text semigraphics with block elements and dithering patterns.

   
ZX81 semigraphics

The BBC Micro could utilise the Teletext 7-bit character set, which had 128 box-drawing characters, whose code points were shared with the regular alphanumeric and punctuation characters. Control characters were used to switch between regular text and box drawing.[4]

The BBC Master and later Acorn computers have the soft font by default defined with line drawing characters.

0 1 2 3 4 5 6 7 8 9 A B C D E F
A โ•ท โ•ถ โ”Œ โ•ด โ” โ”€ โ”ฌ โ•ต โ”‚ โ”” โ”œ โ”˜ โ”ค โ”ด โ”ผ
B โ•ญ โ•ฎ โ•ฐ โ•ฏ

The Amstrad CPC also has soft characters defined by default as block and line drawing characters.

0 1 2 3 4 5 6 7 8 9 A B C D E F
8 โ–˜ โ– โ–€ โ–– โ– โ–ž โ–› โ–— โ–š โ– โ–œ โ–ƒ โ–™ โ–Ÿ โ–‰
9 โ•ต โ•ถ โ”” โ•ท โ”‚ โ”Œ โ”œ โ•ด โ”˜ โ”€ โ”ด โ” โ”ค โ”ฌ โ”ผ

The CP/M Plus character set used on various Amstrad computers of the CPC, PCW and Spectrum families included a rich set of line-drawing characters as well:[5][6][7]

[5] 0 1 2 3 4 5 6 7 8 9 A B C D E F
8 โ•ง โ•Ÿ โ•š โ•ค โ•‘ โ•” โ•  โ•ข โ• โ• โ•ฉ โ•— โ•ฃ โ•ฆ โ•ฌ
9 โ•ต โ•ถ โ”” โ•ท โ”‚ โ”Œ โ”œ โ•ด โ”˜ โ”€ โ”ด โ” โ”ค โ”ฌ โ”ผ

MouseText is a set of display characters for the Apple IIc, IIe, and IIgs that includes box-drawing characters.

Some recent embedded systems also use proprietary character sets, usually extensions to ISO 8859 character sets, which include box-drawing characters or other special symbols.

The World System Teletext (WST) uses pixel-drawing characters for some graphics. A character cell is divided in 2ร—3 regions, and 26 = 64 code positions are allocated for all possible combinations of "pixels".[8] These characters were added to the Unicode standard in Version 13.[9]

Character codeEdit

On many platforms, the character shape is determined programmatically from the character code.

ZX Spectrum block characters: 0x80 + topright*1 + topleft*2 + bottomright*4 + bottomleft*8

Amstrad CPC block characters: 0x80 + topleft*1 + topright*2 + bottomleft*4 + bottomright*8

Amstrad CPC line characters: 0x90 + up*1 + right*2 + down*4 + left*8

BBC Master line characters: 0xA0 + down*1 + right*2 + left*4 + up*8

Teletext block characters: 0xA0 + topleft*1 + topright*2 + middleleft*4 + middleright*8 + bottomleft*16 + bottomright*64

DOS linedraw characters are not ordered in any programmatic manner, and calculating a particular character shape needs to use a look-up table.

ExamplesEdit

Sample diagrams made out of the standard box-drawing characters, using a monospaced font:

โ”Œโ”€โ”ฌโ”  โ•”โ•โ•ฆโ•—  โ•“โ”€โ•ฅโ•–  โ•’โ•โ•คโ••
โ”‚ โ”‚โ”‚  โ•‘ โ•‘โ•‘  โ•‘ โ•‘โ•‘  โ”‚ โ”‚โ”‚
โ”œโ”€โ”ผโ”ค  โ• โ•โ•ฌโ•ฃ  โ•Ÿโ”€โ•ซโ•ข  โ•žโ•โ•ชโ•ก
โ””โ”€โ”ดโ”˜  โ•šโ•โ•ฉโ•  โ•™โ”€โ•จโ•œ  โ•˜โ•โ•งโ•›
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  โ•”โ•โ•โ•โ•— Some Text  โ”‚โ–’
โ”‚  โ•šโ•โ•ฆโ•โ• in the box โ”‚โ–’
โ•žโ•โ•คโ•โ•โ•ฉโ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•กโ–’
โ”‚ โ”œโ”€โ”€โ”ฌโ”€โ”€โ”ค           โ”‚โ–’
โ”‚ โ””โ”€โ”€โ”ดโ”€โ”€โ”˜           โ”‚โ–’
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ–’
 โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’โ–’

See alsoEdit

ReferencesEdit

  1. ^ Box Drawing U+2500-U+257F, The Unicode Standard Code Charts
  2. ^ a b Hewlett-Packard - Technical Reference Manual - Portable PLUS (1 ed.). Corvallis, OR, USA: Hewlett-Packard Company, Portable Computer Division. August 1985. 45559-90001. Retrieved 2016-11-27.
  3. ^ a b Hewlett-Packard - Technical Reference Manual - Portable PLUS (PDF) (2 ed.). Portable Computer Division, Corvallis, OR, USA: Hewlett-Packard Company. December 1986 [August 1985]. 45559-90006. Archived (PDF) from the original on 2016-11-28. Retrieved 2016-11-27.
  4. ^ Broadcast Teletext Specification, September 1976 (as HTML or scans of original document)
  5. ^ a b "Appendix II: CP/M Plus character sets / II.1 The complete character set (Language 0)". Spectrum +3 CP/M Plus manual (User Manual). Archived from the original on 2009-10-15. Retrieved 2017-07-10. [1]
  6. ^ Elliott, John C. (2015-04-04). "Amstrad Extended BIOS Internals". Seasip.info. Archived from the original on 2017-07-15. Retrieved 2017-07-15.
  7. ^ "Amstrad CP/M Plus character set". Archived from the original on 2017-07-15. Retrieved 2017-07-15.
  8. ^ Wiels. "TeleText - Het Protocol" (in Dutch). Mosaic characters. Archived from the original on 2017-12-22. Retrieved 2017-12-21.
  9. ^ "Symbols for Legacy Computing" (PDF). Unicode Consortium. Retrieved 2020-04-19.
Retrieved from ""