Tony wrote:

> gvim 8.2.2267 (Big) with GTK3 GUI; 'encoding' = utf-8; 'filencodings'
> (plural) = ucs-bom,utf-8,latin1
> 
> Steps to reproduce:
> 1. Load a Latin1 file containing only characters in the range
> 0x00-0x7F. (In my case this was a corrupt version of the file.)
> -- 'fileencoding' is set to utf-8, which at this point is acceptable,
> since the de-facto encoding is us-ascii, which is byte-compatible with
> both Latin1 and UTF-8.
> 2. Replace the file-on-disk (by non-Vim methods) by a version
> containing one or more (Latin1) characters in the range 0x80-0xFF. (In
> my case this was the correct version of the file, after fetching it
> over the Net.)
> -- Vim gives a prompt, with options [O]K, [L]oad file
> 3. Answer l (Load).
> -- File is reloaded, but the 'fileencodings' heuristic is not
> reapplied: 'fileencoding' (singular) is still utf-8, any Latin1
> characters above 0x7F (which are not valid UTF-8 byte sequences) are
> changed to question marks. No error for invalid byte sequences (I
> didn't notice any at the time, and none is recorded in the :mess
> messages list).

Hmm, I would expect some warning being given.

> 4. Make some more changes inside Vim, adding more characters in the
> range 0x7F-0xFF, then save.
> -- File is saved as UTF-8; if read as Latin1 outside of Vim, weird
> characters appear where changes were made at step 4. <-- bad
> 5. :setl fenc=latin1 | w
> -- If reloaded outside of Vim, the weird characters have now
> disappeared; but the question marks, if not replaced by what they
> should be, are still there.

This is a very specific sequence of events, which should not happen very
often.  I'm sure that if we re-detect the encoding that it will be wrong
in another situation.  I think that if you would notice the wrong
encoding and used ":edit" that it would do the detection.

-- 
hundred-and-one symptoms of being an internet addict:
90. Instead of calling you to dinner, your spouse sends e-mail.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202101021303.102D3g1I1825583%40masaka.moolenaar.net.

Raspunde prin e-mail lui