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