Re: Translating \ escape codes

From: Måns Rullgård (
Date: 05/19/05

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

> Kasper Dupont <> 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

Måns Rullgård