Re: Best way to handle DOS newlines
On Mon, May 07, 2007 at 05:59:43PM -0700, you (Ray Van Dolson) wrote:
> I occasionally get emails generated from a web application here at work
> that uses DOS/Windows newlines instead of Unix ones. All the text
> shows up as one large line interspersed with ^M^M's. I'd like to
> figure out a good way to:
>
> 1. Correct this in the pager view of the message.
> 2. Correct this prior to the message being passed to my editor (vim)
> for quoting.
>
> Currently I am resolving 1 by using the following message-hook:
>
> message-hook '~f ChangeControl.System@xxxxxxxx' 'set display_filter="sed -f
> ~/bin/fix_m.sed"'
>
> Where fix_m.sed strips out the ^M's and replaces them with my preferred
> newlines.
>
> However, if I hit reply to this message, everything shows up in vim in
> the original format -- ie with the ^M's all intact and everything on
> one line.
>
> I can correct this from wtihin vim, but I'd prefer it all be automated.
>
> I tried a reply-hook similar to my message-hook above, but had no
> success.
>
> Any suggestions?
>
> Ray
Hi Ray,
my suggestion is to use iconv instead of your script.
here part of the man page:
"
NAME
iconv - Convert encoding of given files from one encoding to another
SYNOPSIS
iconv -f encoding -t encoding inputfile
DESCRIPTION
The iconv program converts the encoding of characters in inputfile from one
coded character set to another. The result is written to standard output unless
otherwise specified by the --output option.
"
as far as I understand it, removing the end_of_line characters does not change
the encoding of your original file - and that's why vim
will show these again, even you removed them.
markus