I have this textfile that contains three lines:

        3
        2
        1

Now do:
        :se fileencoding=utf8 bomb
        :%!sort

Result:
        1
        2
        <feff>3

Now do:
        :w newfile
        "newfile" [New] 3L, 12C written
        :w !od -c 
        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:
ï » ¿ (in octal: \357 \273 \277).  Trying to remove them, he typed "xxx", then
wrote the file and quit Vim.  Then he started Vim again, did some more editing
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 latin1.
This helped, but only later I figured out what had happened.

What do you think?

Adri

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

Raspunde prin e-mail lui