I guess, you're asking how to save the file with a BOM? For that, ":set bomb" before saving will do the trick.
To detect this automatically, be sure that you have "set encoding=utf-8", "setglobal bomb", and "set fileencodings=ucs-bomb,utf-8,latin1" or similar in your .vimrc.
Erhy
Erhy
if has("multi_byte")
echomsg "has MULTIBYTE"
if &termencoding == ""
let &termencoding = &encoding
endif
setglobal encoding=utf-8
set encoding<
setglobal fileencoding=utf-8
set fileencoding<
setglobal bomb
set bomb<
setglobal fileencodings=ucs-bom,utf-8,latin1
set fileencodings<
endif
I will accept the converted message because
saving the file, the converted message appears again
and the resulting BOMB is the same.
This all for exported tasks from Windows Task Scheduler.
Erhy
The repeated mails detected by Gabriele
were created because I want to correct them (delete and asnwere again)
Erhy
The results of my test are:
Edit existing files with VIM are written back in the same UTF/UNICODE/ANSI code as originally.
Creating a new file differs
Notepad accepts all characters e.g. by paste text from a page with IE
and warns on saving the file in ANSI format when there are UNICODE characters.
With VIM UNICODE characters pasted are not shown as expected.
A corrective is
set encoding=utf-8
Because I prefer to have the same result as with Notepad
I put additionally
set bomb
"additional lines in my _vimrc
"
setglobal nofixendofline
set fixendofline<
"
if has("multi_byte")
if &termencoding == ""
let &termencoding = &encoding
endif
setglobal fileencodings=ucs-bom,utf-8,latin1
set fileencodings<
endif
"
I'm sure I intentionally used "setglobal bomb". When I experiment with "gvim -N -u NONE -i NONE" and then ":set encoding=utf-8" and ":setglobal bomb", any new buffer I create *after* this via ":new" will automatically get 'bomb' set. If I omit the ":setglobal bomb" then new buffers do NOT get 'bomb' set by default.
Note that the initial buffer created on Vim startup will not have 'bomb' set from the setglobal command. If you need that first buffer to also have 'bomb' set then yes, you will need a setlocal or set command as well.