Adri Verhoef wrote:

> I have this textfile that contains three lines:
> 
>       3
>       2
>       1
> 
> Now do:
>       :se fileencoding=3Dutf8 bomb
>       :%!sort
> 
> Result:
>       1
>       2
>       <feff>3
> 
> Now do:
>       :w newfile
>       "newfile" [New] 3L, 12C written
>       :w !od -c=20
>       0000000 357 273 277   1  \n   2  \n 357 273 277   3  \n
>       0000014
> 
> I think there is a problem here, namely that the BOM (Byte Order Mark, see
> :help 'bomb') is transferred to the shell command, when it shouldn't.  In
> my opinion Vim should be able to temporarily remove the BOM, then execute
> the shell command, and finally place the BOM back at its original place,
> at the beginning of the file.
> 
> Background: a colleague of mine received a file from abroad (with afterwards
> what appeared to be a BOM) and while editing the file, he sorted the file
> (:%!sort) and noticed some strange characters at the end of the file.  Since
> his terminal can't handle UTF-8, he saw these three characters in Latin-1:
> =EF =BB =BF (in octal: \357 \273 \277).  Trying to remove them, he typed "xx=
> x", then
> wrote the file and quit Vim.  Then he started Vim again, did some more editi=
> ng
> and sorted the file again and saw - again - those three strange characters,
> erased them again and sorted again and there they were *again*!  It puzzled =
> me
> for a while, too, until I adviced him to try setting 'fileencoding' to latin=
> 1.
> This helped, but only later I figured out what had happened.
> 
> What do you think?

The problem is with using an encoding that the sort command doesn't
understand.

You could remove the BOM to work around the problem.  Or use the
internal ":sort".

In general, if you edit files with Vim that have a BOM, filtering them
with an external command should work like filtering the original file.
Thus that includes the BOM.

I'm not sure if Vim should detect (and remove) a BOM halfway a file.
You can get it with some filter commands and concatenating files.
Perhaps we need a command ":delboms"?  And ":delbombs" for people who
can't remember the command name :-).

-- 
Biting someone with your natural teeth is "simple assault," while biting
someone with your false teeth is "aggravated assault."
                [real standing law in Louisana, United States of America]

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui