home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19286 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.7 KB

  1. Path: sparky!uunet!news.claremont.edu!nntp-server.caltech.edu!goblin!mcs
  2. From: mcs@goblin.caltech.edu (Martin Shepherd)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Hex escaping in strings, (porting from gcc to cc)
  5. Date: 6 Jan 1993 04:02:21 GMT
  6. Organization: California Institute of Technology, Pasadena
  7. Lines: 33
  8. Message-ID: <1idlkdINNgbg@gap.caltech.edu>
  9. References: <1ifpjnINNkck@zephyr.grace.cri.nz> <C0ELuw.Hsv@portal.hq.videocart.com>
  10. NNTP-Posting-Host: goblin.caltech.edu
  11.  
  12.  
  13. In article 63463 in comp.lang.c dfuller@portal.hq.videocart.com says:
  14. :chrisp@grace.cri.nz writes:
  15. :: Hi,
  16. ::   I have a problem with porting from gcc to cc (on a sun sparc station)
  17. :: 
  18. ::       puts("\x1b=");          /* set's the terminals keypad mode */
  19. :: 
  20. ::  Works fine with gcc, the "\x1b" is interpreted as ascii 27, escape.  But
  21. ::  on cc it just prints "x1b=".
  22. :: 
  23. ::  Is the hex code escape an ansii extension,  how else can I do it?, I would
  24. ::  rather avoid:
  25. ::       sprintf(tmp,"%c=",27);
  26. :: 
  27. ::                               Thanks,  Chris.    chrisp@grv.grace.cri.nz
  28. :    You'll have to forgive me, i dont use gcc, and i dont keep track of
  29. : the ANSI standard very well. What you have here is probably an extension 
  30. : of gcc. The \ is used to escape n b t and a. Maybe others. It would appear
  31. : that gcc added x as an escape for translating hex codes. What you need to
  32. : do to make this work is to change the x1b to its octal value. This is 
  33. : understood in ANSI C. 
  34.  
  35. Hexadecimal escape sequences were added in ANSI C - see pages 193-194
  36. of K&RII for details. The reason that it didn't work in this case is
  37. that SUN's cc is not ANSI.
  38.  
  39. : so puts("\x1b=")  ---->>>   puts("\033=")
  40.  
  41. This should work.
  42.  
  43. Martin Shepherd  (mcs@phobos.caltech.edu)
  44.