How to Lookup an ASCII Table in Linux
If your author smartphone apps or you’re a Web developer, then the time might come that you need some advanced information on how apps interact with individual characters. While we view characters like letters, numbers, and symbols, the underlying system code sees them only as a series of numeric values. Programming an app or authoring a Web page could be easier if you know the specific numeric values that are mapped to different characters. These numeric values are more or less platform-independent, so if you author your own code on Linux for use on another platform knowing these values from inside Linux is still worthwhile.
Linux has a number of built-in programmer tools to solve these sorts of problems, but they’re largely obscured from modern users. This technology is still quite useful, especially in a world that demands more and more development for mobile platforms. After you know the tricks to access this information, you’ll find that it’s much faster than looking it up on the Internet or reaching for an actual coder’s manual.
Method 1: From the Terminal
If you’re already within a Linux CLI environment operating from the Bash shell, then you can use the built-in Linux Programmer’s Manual without skipping a beat. At the Bash prompt, type the command man ASCII and then push enter. You’ll be greeted with the technical definition of what ASCII is, followed by a table of the 128 characters that make up the proper ASCII standard.
More than likely you’ve become quite accustomed to looking up the manual pages for commands using the CLI man command, but you may not be as used to the built-in Linux Programmer’s Manual. Many man pages that otherwise wouldn’t be referenced by command names can be accessed in the same way.
Scroll down either with the mouse scroll wheel, by pressing the Page Down key or pushing the down arrow key on your keyboard. You can explore a very detailed page that provides several full ASCII tables. Simply swipe with the mouse to highlight text and then hold down CTRL and SHIFT while pressing C to copy; any information you copy can then be pasted in another window.
Method 2: With the Graphical Manual Pages Tool
Hold down the Windows or Super key and push R to open up a run dialog box. Type xman in the box and then push enter or click on OK to proceed.
A small dialog box entitled xman will pop up as soon as you do so. Click on “Manual Page” inside of this stark white box.
An Xman Help window will pop up, explaining how this is the X Window System manual browsing tool. Ignore this text, instead click on “Options” and select the “Search” function.
A search box will come up separate from the Manual Page explanation screen. Type ascii in the search box and then click on the Manual Page button.
You will now see the same Linux Programmer’s Manual page that you would have if you had used the CLI function. Scroll with the mouse wheel to view the ASCII tables or push the ‘F’ key or space bar to move down a page at a time.
While the xman command has largely been deprecated, it’s still included with XFree, and you could theoretically use it to look up any command or built-in Linux Programmer’s Manual man page by following this same process. You could also use it to browse every man page that’s installed on your system by using the same menu prompt system you used to access the ASCII programmer’s page.
Method 3: With a Shell Script
If you find yourself becoming reliant on this table for programming tasks, then you may wish to automate the process of finding the tables with a Bash shell script. From the Linux CLI interface, use the cd command to locate yourself in a logical location. For instance, you may wish to use cd ~/.local/bin to place your script in an area where it will be easily accessible regardless of where you are. Once you’re where you want to create the script, type cat > asciiShow and push enter. Then type #!/bin/bash followed by entering and then man ascii | grep -A 20 Tables followed by enter. Then push CTRL and D at the same time. Having returned to the regular prompt, type chmod +x asciiShow to make your new script executable, push enter, and then type ./asciiShow followed by enter to run it.
Method 4: With a Text File
Instead of going through the difficulty of creating a script, you could also redirect the output of this command to a text file to examine with whichever text editor you would like. Use the cd command to find an appropriate place to put your text file. For instance, you may wish to type cd ~/Documents to get to your regular documents folder. Once there type man ascii | grep -A 20 Tables > asciitables and push enter.
Now you may edit this file with whatever software you’d like. You may type cat asciitables and then push enter to output it to the terminal. If you navigate to ~/Documents in a graphical file manager and double click on the asciitables icon there you could open it in a graphical text editor.
Method 5: With the showkey Command
If you’re in need of a specific code, then you can access the built-in ASCII tables interactively. Type showkey -a at the CLI Bash prompt and press enter. You will be greeted with a message that reads “Press any keys – Ctrl-D will terminate this program” followed by a cursor. Press whichever key you need to see the numerical codes of to receive the requested output, and then press CTRL and D at the same time to exit.
This can be a great way to find character information while you’re writing source code.