Re: Translating \ escape codes

From: Måns Rullgård (mru_at_inprovide.com)
Date: 05/19/05


Date: Thu, 19 May 2005 15:40:18 +0200

Jens.Toerring@physik.fu-berlin.de writes:

> Kasper Dupont <kasperd@daimi.au.dk> wrote:
>> Is there some standard function to take one string
>> and create a new one where \ escape codes have been
>> translated like the C compiler does? None of the
>> functions mentioned in man string.h seemed appropriate.
>
> None that I would know of. But you can have the one I once wrote for
> exactly this purpose (what it doesn't do is trying to deal with tri-
> graphs, and the handling of octal and hexadecimal values is a bit
> more liberal than what's expected in C, i.e. what's following '\x'
> can be either 1 or two hexadecimal chars instead of exactly 2 and
> an octal number can consist of 1, 2 or 3 digits instead of just 3).

That's what gcc does. I'm not sure what the standards say. As for
your implementation, all those memmove() calls seem a little
inefficient.

-- 
Måns Rullgård
mru@inprovide.com


Relevant Pages

  • Re: Standard function to convert " " to (etc.)?
    ... The corresponding argv will be a null terminated string holding 4 ... Is there a standard function which will convert that to the null ... It should also handle the other C defined characters, ... and another being octal escapes. ...
    (comp.lang.c)
  • Re: Translating escape codes
    ... > Is there some standard function to take one string ... > and create a new one where \ escape codes have been ... * Function replaces all C type escape sequences in a string (in ...
    (comp.os.linux.development.apps)
  • Re: disturbed between two versions
    ... strdup is not a standard function. ... the desired string in allocated memory and I assume this is what ... Otherwise tokens will be truncated. ... a pointer past the terminating tokchar. ...
    (comp.lang.c)
  • Re: Strings in C are less optimal than in (say) Pascal - correct?
    ... >> combines with a standard function to produce really slow code. ... > middle of a string as a pointer to the tail of the string). ... instead use a localled defined header). ... > a standard header with a more sophisticated dynamic string type. ...
    (comp.lang.c)
  • Translating escape codes
    ... Is there some standard function to take one string ... and create a new one where \ escape codes have been ... translated like the C compiler does? ...
    (comp.os.linux.development.apps)