<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> <TITLE>Bash Prompt HOWTO: Caratteri Speciali: Sequenze di Escape Ottali</TITLE> <LINK HREF="Bash-Prompt-HOWTO-7.html" REL=next> <LINK HREF="Bash-Prompt-HOWTO-5.html" REL=previous> <LINK HREF="Bash-Prompt-HOWTO.html#toc6" REL=contents> </HEAD> <BODY> <A HREF="Bash-Prompt-HOWTO-7.html">Avanti</A> <A HREF="Bash-Prompt-HOWTO-5.html">Indietro</A> <A HREF="Bash-Prompt-HOWTO.html#toc6">Indice</A> <HR> <H2><A NAME="s6">6. Caratteri Speciali: Sequenze di Escape Ottali</A></H2> <P>Oltre i caratteri che si digitano sulla tastiera, ci sono molti altri caratteri che possono essere stampati sullo schermo. Ho creato uno script per permettervi di controllare cosa mette a disposizione il font che state usando. Il comando principale che avrete bisogno di usare è per utilizzare questi caratteri è "echo -e". L'opzione "-e" dice ad echo di abilitare l'interpretazione dei caratteri protetti con backslash. Cosa si vede quando guardate 200-400 ottale è molto diverso con un font VGA da quello che si vede con un font Linux standard. Siate avvisati che queste sequenze di escape hanno effetti strani sul terminale, e non ho tentato di prevenire che facciano quello che fanno. I caratteri linedraw e block (ai quali molti di noi sono diventati familiari con Word Perfect) e che sono usati molto dal progetto Bashprompt, sono fra 260 e 337 ottale. <P> <HR> <PRE> #!/bin/bash # Script: escgen function usage { echo -e "\033[1;34mescgen\033[0m <lower_octal_value> [<higher_octal_value>]" echo " Octal escape sequence generator: print all octal escape sequences" echo " between the lower value and the upper value. If a second value" echo " isn't supplied, print eight characters." echo " 1998 - Giles Orr, no warranty." exit 1 } if [ "$#" -eq "0" ] then echo -e "\033[1;31mPlease supply one or two values.\033[0m" usage fi let lower_val=${1} if [ "$#" -eq "1" ] then # If they don't supply a closing value, give them eight characters. upper_val=$(echo -e "obase=8 \n ibase=8 \n $lower_val+10 \n quit" | bc) else let upper_val=${2} fi if [ "$#" -gt "2" ] then echo -e "\033[1;31mPlease supply two values.\033[0m" echo usage fi if [ "${lower_val}" -gt "${upper_val}" ] then echo -e "\033[1;31m${lower_val} is larger than ${upper_val}." echo usage fi if [ "${upper_val}" -gt "777" ] then echo -e "\033[1;31mValues cannot exceed 777.\033[0m" echo usage fi let i=$lower_val let line_count=1 let limit=$upper_val while [ "$i" -lt "$limit" ] do octal_escape="\\$i" echo -en "$i:'$octal_escape' " if [ "$line_count" -gt "7" ] then echo # Put a hard return in. let line_count=0 fi let i=$(echo -e "obase=8 \n ibase=8 \n $i+1 \n quit" | bc) let line_count=$line_count+1 done echo </PRE> <HR> <P> <P>Potete anche usare <B>xfd</B> per mostrare tutti i caratteri un un font X, con il comando "xfd -fn <fontname>". Facendo clic su un carattere vengono date molte informazioni circa quel catattere, incluso il suo valore ottale. Lo script dato sopra sarà utile alla consolle e se non siete sicuri del nome del font corrente. <P> <HR> <A HREF="Bash-Prompt-HOWTO-7.html">Avanti</A> <A HREF="Bash-Prompt-HOWTO-5.html">Indietro</A> <A HREF="Bash-Prompt-HOWTO.html#toc6">Indice</A> </BODY> </HTML>