home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!portal!dfuller
- From: dfuller@portal.hq.videocart.com (Dave Fuller)
- Subject: Re: Hex escaping in strings, (porting from gcc to cc)
- Message-ID: <C0ELuw.Hsv@portal.hq.videocart.com>
- Organization: VideOcart Inc.
- X-Newsreader: Tin 1.1 PL3
- References: <1ifpjnINNkck@zephyr.grace.cri.nz>
- Date: Tue, 5 Jan 1993 23:13:44 GMT
- Lines: 41
-
- 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.
-
- so puts("\x1b=") ---->>> puts("\033=")
-
- to put multiple escape chars together it would be puts("\033\033=");
-
- you get the point.
-
- chars may be represented as octal values when initialized.
-
- char ch_1 = 'X',
- ch_2 = '\130',
- ch_3 = 0130;
-
- gives the same value to all of the char variables.
-
-
- Dave Fuller
- dfuller@portal.hq.videocart.com
-
-
-