Control M ????
Rupert Wood
me@rupey.net
Tue Feb 12 05:14:00 GMT 2002
Kabir Patel wrote:
> Some time back I mentioned a problem I had with the ^M character
> (see below). It so happens that I need to be able to replace every
> ^M in my resultant file with a " " charachter. GNU isn't happy with
> ^M. Is there a way to define ^M in another way?
Yes, this is exactly the problem you had before.
^M is ASCII 13, representing carriage return (CR); hence you could
replace the single character constant '^M' with any of the following:
13
'\x0d' (backslash x zero d: 0d is hexadecimal for 13)
'\r'
(or the octal string escape represntation, or hex or octal immediates,
etc.)
The last is a special C-escape for CR and perhaps the most useful
representation since it describes the intended meaning here. (On the
other hand, this might not be appropriate if you're specifically dealing
with PC text files guaranteed to be 13-10 and the host system's CR might
not be 13 or something - I guess it's a style call.)
If you have ^M in the middle of a string then you should replace it with
a string constant escape such the latter two, \x0d or \r.
Rup.
More information about the Gcc-help
mailing list