main page next

Dokumenthantering VT97:01

These are the exercises and references for the first class of the course Dokumenthanteringen


Exercises

  1. The command printf can be used under Unix to convert decimal numbers to octal or hexadecimal values. Examples:

    printf "octal: %o\n" 224
    printf "hexadecimal: %x\n" 224

    In the first string %d will print a decimal number, %o will print an octal number and %x (or %X) will print a hexadecimal number. The number behind the string (in this case 224) will be interpreted as a decimal number. Use this printf command to verify the numbers shown in the table in section 1.1. The same can be done with the following perl script:

    #!/usr/local/bin/perl
    for (4,10) {
       printf "decimal %3d; octal %3o; hexadecimal %3x\n", $_, $_, $_;
    }
    

  2. The control characters can also be printed with printf. Try running:

    #!/usr/local/bin/perl
    printf "%c%c%c%ca%cb%c\n", 7, 10, 13, 127, 8;
    

    The %c will print a character with the decimal ASCII value which has been specified behind the string. The result will depend on the terminal configuration you are using. The a or the b may be deleted by the next control character and you may here a bell. Try running the command and piping it to the more command. This should remove the bell sound and show ^G.

  3. Our AIX machines have all ISO 8859 available except ISO 8859-10. You can display the font in a terminal window by using the command asciiTable. Every window can display only one character set. You can start a window with a different character set (font) by starting the window program on the command line with arguments -fn FONT where FONT is an X windows font. You can use the command xlsfonts to get an overview of the available fonts.

    Example:

    xterm -fn -urw-courier-medium-r-normal--13-100-100-100-m-80-iso8859-5

    starts an xterm window with font ISO 8859-5 size 13.

    You can also work with the different character sets by starting one of the programs aixterm1, aixterm2, and so on or emacs1, emacs2 and so on. These programs start either aixterm or emacs with the font ISO 8859-X in which X is the digit in the program name. Again you can get an overview of the characters that are being used by typing asciiTable in one of the aixterm windows.

    Use these overviews and the web page mentioned in the references to choose the best ISO 8859 character set for displaying an aligned text in Swedish and Slovenian. The character set should include as many as possible characters with diacritics of both languages. For Swedish the lower case characters with diacritics are å, ä, ö and é. For Slovenian these are

    v    v       v
    c,   s  and  z.
    

  4. Attempt to write a Perl script that performs the same task as asciiTable.


References


Last update: Februari 10, 1997. erikt@stp.ling.uu.se