home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / os2 / programm / 3681 < prev    next >
Encoding:
Text File  |  1992-07-20  |  3.2 KB  |  81 lines

  1. Path: sparky!uunet!cs.utexas.edu!gateway
  2. From: HARPER@VTVM1.CC.VT.EDU (Scott Harper)
  3. Newsgroups: comp.os.os2.programmer
  4. Subject: ANSI troubles
  5. Date: 21 Jul 1992 02:14:15 -0500
  6. Organization: UTexas Mail-to-News Gateway
  7. Lines: 69
  8. Sender: daemon@cs.utexas.edu (The devil himself)
  9. Message-ID: <9207210713.AA12418@cs.utexas.edu>
  10. NNTP-Posting-Host: cs.utexas.edu
  11.  
  12. Although I posted this in comp.os.os2.programmer a while ago, I have not
  13. heard any response.  I thought I might try again with source code in case
  14. nobody knew what I was refering to.
  15.  
  16. I seem to be having a problem with OS/2's ANSI.SYS (I think).  I have a
  17. DOS program that uses the C library function outtextxy(col,row,outstring).
  18. This function writes a text string to a graphics screen.  When I attempt
  19. to write characters with ASCII values above 127 (a few symbols past the
  20. lower case letters), I get rather odd characters.  They are not part of
  21. any code page that I have ever seen.  Note: I am using codepage 437 (437
  22. & 850 prepared in config.sys).  Strangly enough, the code page looks
  23. competely correct if I use the text mode function putch() or if I use the
  24. alt-keypad combinations at a prompt.
  25.  
  26. I am using the BGI libraries (from the Borland C++ 3.0 package) to enable
  27. graphics.  Perhaps they are at fault?  As a final note, this program prints
  28. the correct characters from pure DOS (or a DOS 5.0 image).
  29.  
  30. Perhaps someone who is doing DOS development under OS/2 has seen this before?
  31. I've attached the code for a program that will demonstrate the difference
  32. between the two code pages for anyone interested in seeing it for themselves.
  33.  
  34. .............................................................................
  35.   Scott Harper                 ___   The moral of the story is: Never under-
  36.                                \_ \_    estimate the bandwidth of a station
  37.                                   \ \      wagon full of tapes hurtling down
  38.                                     \_\_      the highway.
  39.    EMail: HARPER @ VTVM1.cc.vt.edu     \\
  40.                                          *            - Andrew S. Tanenbaum
  41. .............................................................................
  42.  
  43.  
  44. /* This program prints both the text-mode character set and the graphics-mode
  45.    character set beside each other on a VGA or EGA screen.  Graphics
  46.    characters are displayed in red, text in gray.                            */
  47.  
  48. #include <stdlib.h>
  49. #include <conio.h>
  50. #include <stdio.h>
  51. #include <graphics.h>
  52.  
  53. void main(void)$
  54.  
  55.    int x,y=0;
  56.    char outstring[2]=$0,'\0';
  57.    int driver=DETECT;
  58.  
  59.    /* It may be necessary to add the path to your bgi drivers to the
  60.       initgraph function if you have not added the object files to your
  61.       graphics.lib                                                     */
  62.  
  63.    if(registerbgidriver(EGAVGA_driver)<0) exit(1);
  64.  
  65.    initgraph(&driver,0,"");
  66.    if(x=graphresult())$
  67.       printf("Graphics initialization error: %s\n",grapherrormsg(x));
  68.       exit(1);
  69.    clearviewport();
  70.  
  71.    setcolor(EGA_LIGHTRED);
  72.    settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
  73.  
  74.    for(x=1; x<=255; x++)$
  75.       outstring[0] = x;
  76.       if(!(x%20))y++;
  77.       gotoxy((x%20+1)*4,y+1); printf("%c",x);
  78.       outtextxy((x%20)*32+10,y*16+4,outstring);
  79.       
  80. 
  81.