The proper way to display high ASCII characters on a linux console.
1#include <stdio.h> 2#include <stdlib.h> 3#include <getopt.h> 4 5main(int argc, char *argv[]) 6{ 7 int i=33, hex=0, extended=0; 8 9 while (optind < argc) {10 switch (getopt(argc, argv, "dehxf")) {11 case 'd': /* decimal */12 hex=0;13 break;14 case 'e': /* extended vt100 chars */15 extended=1;16 break;17 case 'h': /* help screen */18 printf("%s usage:\n",argv[0]);19 printf("\t%s [ -d | -x ] [ -f ] [ -e ]\n", argv[0]);20 printf("\t-d - print out index in decimal\n");21 printf("\t-x - print out index in hexidecimal\n");22 printf("\t-f - full printout - don't skip control characters\n");23 printf("\t-e - Use ^N and ^O to enable some vt100 graphics\n");24 exit(0);25 break;26 case 'x': /* hex */27 hex=1;28 break;29 case 'f': /* full */30 i=0;31 break;32 }33 }34 35 /* i is set above */36 for (;i <= 255; i++) {37 /* print the number of the char, and the char */38 if (hex)39 printf(" %x ", i);40 else41 printf(" %d ", i);42 if (extended)43 printf("\xe%c\xf\t", i);44 else45 printf("%c\t", i);46 /* wrap to next line after 8 chars */47 if (i % 8 == 0) puts("");48 }49 puts("");50}