ASCII(1plan9)

πŸ’« NAME πŸ’«

ascii, unicode β€” interpret ASCII and Unicode characters, aka the translators that turn characters into numbers and numbers back into characters (bestie, this is the whole personality of the page) ✨


πŸŽ€ SYNOPSIS πŸŽ€

ascii [ -8 ] [ -oxdbn ] [ -nct ] [ text ]

unicode [ -nt ] hexmin-hexmax

unicode [ -t ] hex [ ...  ]

unicode [ -n ] characters

look hex /lib/unicode

🌸 DESCRIPTION 🌸

ascii prints the ASCII values that go with characters, and it also goes the other way around β€” values to characters. Lowkey a two-way street πŸ¦‹. If you pass the -8 option, the ISO Latin-1 extensions get included too, and those are the codes 0200-0377. The values get interpreted in a numeric base you can set: -o says octal, -d says decimal, -x says hexadecimal (and hex is the default, no cap), and -bn sets base n. πŸŽ€

With no arguments at all, ascii prints a table of the character set in whichever base you specified. Characters of text get converted into their ASCII values, one per line. But β€” plot twist β€” if that first text argument is a valid number in the specified base, the conversion flips and goes the opposite direction instead. Control characters come out as two- or three-character mnemonics. πŸ’…

Other options, bestie, here they are:

  • -n β€” Force numeric output. Like, make it numbers, periodt.
  • -c β€” Force character output. The opposite vibe πŸ’–.
  • -t β€” Convert from numbers to running text; it does not interpret control characters and does not insert newlines. Just raw running text, the way that it flows 🌈.

unicode is basically the same energy; it converts between UTF and character values from the Unicode Standard (go see utf(7) if you're curious). If you hand it a range of hexadecimal numbers, unicode prints a table of the Unicode characters you asked for β€” their values and their UTF representations ✨. Otherwise it translates from UTF to numeric value or the other way around, depending on how the supplied text looks. The -n option forces numeric output, which is how you dodge the ambiguity with numeric characters. If it's converting to UTF, the characters get printed one per line unless the -t flag is set β€” and when -t is set, the output is a single string containing only the characters you specified. Oh, and unlike ascii, unicode treats no characters specially. Not one. Iconic behavior πŸ‘‘.

Heads up though πŸ™ˆ: the output of ascii and unicode may be unhelpful if the characters being printed aren't available in the current font. Not their fault, it's giving font issues.

Also, the file /lib/unicode holds a table of characters and descriptions, sorted in hexadecimal order, and it's suitable for look(1) on the lower case hex values of characters πŸ¦‹.


πŸ“ EXAMPLES πŸ“

  • ascii -d Print the ASCII table base 10.
  • unicode p Print the hex value of p.
  • unicode 2200-22f1 Print a table of miscellaneous mathematical symbols. (math girlies rise up ✨)
  • look 039 /lib/unicode See the start of the Greek alphabet's encoding in the Unicode Standard.

🧚 FILES 🧚

  • /lib/unicode table of characters and descriptions.

⭐ SOURCE ⭐

  • /src/cmd/ascii.c
  • /src/cmd/unicode.c

πŸ’œ SEE ALSO πŸ’œ

look(1), tcs(1), utf(7), font(7)


okay and that's the whole page bestie!! this one lives in the ASCII(1plan9) manual, and it's brought to you from /src/cmd/ascii.c and /src/cmd/unicode.c β€” same page title up top and down at the bottom, we're matching πŸ’–βœ¨πŸ«Ά

πŸ“¦ where this page comes from