Click to See Complete Forum and Search --> : What character is this?
hop-frog
10-05-2003, 12:23 AM
I've been working in Lisp and discovered that a strange character must be present in places. For example, it must be placed in front of "[1m" to make the text thereafter bold. The character shows up different in different places. Depending on which application I paste it into it will either look like a solid-lined box, a rectangle formed of little dots, or empty space. (1) How can I find out where this character is on the character map or ASCII chart to access it later and (2) why could the Lisp developers choose to use such a strange character as part of the syntax in the first place?
I've pasted it between these two quotes:
""
michaelk
10-05-2003, 09:11 AM
I haven't used lisp at all but will take an educated guess.
The unusal character you pasted is a non printable ASCII character. Different applications will display these characters differently than others. If you look at the table the first 32 values do not map to a real character so display such a character to the monitor produces a garbarge character.
http://www.asciitable.com/
From what you described the [1m is an escape character sequence. And as you have discovered these commands control how the video is displayed as well as cursor movements etc.
The unusual character since it is at the beginning of the command is the Esc key and ASCII decimal value for Esc is 27. Some apps allow one to use \xxx so in this case \027.
bwkaz
10-05-2003, 02:35 PM
Originally posted by michaelk
Some apps allow one to use \xxx so in this case \027. But \027 means octal character 27, not decimal character 27. Octal 27 is decimal 23 (2 eights and 7 ones is 23), which is not escape. It's Ctrl-W.
If you want to use octal (AKA keep the leading zero, because it's the leading zero that makes it be interpreted as octal), then use \033 (3 eights and 3 ones).
Or, you can use hexadecimal, which would be \x1b (one sixteen, and eleven (b) ones).
Or, you can just stick to decimal, with \27.
Some languages (or some shell commands, like echo) let you use \e, but they seem to be relatively rare.