home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 32 / hot34.iso / ficheros / DUTI / ASCII002.ZIP / ASCII.C next >
Text File  |  1998-03-20  |  2KB  |  70 lines

  1. //<c>   Copyright 1988-1998 by Gerry J. Danen; all rights reserved.
  2.  
  3. //<t>   ASCII Table Generator
  4.  
  5. #include"gd_tools.h"
  6. #include"gd_ansi.h"
  7.  
  8.  
  9. #define pgVERS_ "V2.01"
  10. #define pgTITL_ "ASCII Table Generator"
  11. #define pgCOPR_ "1988"
  12.  
  13.  
  14. #define NAMES 32                        // names of characters less than 0x20
  15. static  UCHAR *ch_names[NAMES] =
  16. {
  17.     "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS",  "HT",
  18.     "LF",  "VT",  "FF",  "CR",  "SO",  "SI",  "DLE", "DC1", "DC2", "DC3",
  19.     "DC4", "NAK", "SYN", "ETB", "CAN", "EM",  "SUB", "ESC", "FS",  "GS",
  20.     "RS",  "US"
  21. };
  22.  
  23.  
  24. void    char_name( int n, char *cname ) // get a name for the character (if any)
  25. {
  26.     strcpy(cname,((n<0) || (n>=NAMES)) ? " " : ch_names[n]);
  27. }
  28.  
  29.  
  30. void    main( int argc, char *argv[] )
  31. {
  32.     register int i, j, k;
  33.     char name[4];
  34.  
  35.     tt_init( SHAREWARE_VERSION, 0, pgVERS_, pgTITL_, pgCOPR_ );
  36.     ansi_cls( 3, stderr );
  37.     logon(1);
  38.  
  39.     printf( "\n ╔═════════════════════╦═════════════════╦═════════════════╗" );
  40.     printf( "\n ║ Sig Chr Dec Hex Oct ║ Chr Dec Hex Oct ║ Chr Dec Hex Oct ║" );
  41.  
  42.     for ( i=0; i < 43; i++ )
  43.     {
  44.         if (argc==1)
  45.             tm_sleep_msecs( 5 );                // delay
  46.         j = i + 43;
  47.         k = j + 43;
  48.         if ( i % 5 == 0 )
  49.             printf( "\n ╠═════════════════════╬═════════════════╬═════════════════╣" );
  50.  
  51.         char_name( i, name );
  52.         if ( i < 32 )
  53.             printf("\n ║ %3s  ^%c  %02d  %02X %03o ", name, (64 + i), i, i, i);
  54.         else
  55.             printf("\n ║ %3s   %c  %02d  %02X %03o ", name, i, i, i, i);
  56.         printf("║   %c  %02d  %02X %03o ", j, j, j, j);
  57.         if ( k < 127 )
  58.             printf("║   %c %3d  %02X %03o ║", k, k, k, k);
  59.         else
  60.         {
  61.             if ( k == 127 )
  62.                 printf("║ DEL %3d  %02X %03o ║", k, k, k);
  63.             else
  64.                 printf("║                 ║" );
  65.         }
  66.     }
  67.     printf( "\n ╚═════════════════════╩═════════════════╩═════════════════╝" );
  68.     exit( 0 );
  69. }
  70.