Tuesday, December 8, 2020

Re: Changing encoding of an already loaded buffer

Albert Wik wrote:

> On Mon, 7 Dec 2020 at 20:49, Gabriele F <gbfv@tiscali.it> wrote:
> >
> > The actual "correct" way to "change" the encoding of a buffer is, I
> > believe, with the "++enc" option, added either to :e (e.g. `:e
> > ++enc=utf8`) or several similar commands such as indeed :vi (`:vi
> > ++enc=utf8`).
>
> Thanks, I didn't know about that. It's more convenient than changing
> the "fileencodings".
>
> > However I couldn't find a way to make it work with a file-less buffer,
> > such as your pipe example:
>
> Right. The only way I've found is to use a temporary file.
> Incidentally, the zsh shell makes that easy:
> % gvim -f =(man llseek)

Assuming that loading the text as latin1 didn't mess it up (since it's
an 8 bit encoding it should be OK), then you can convert it to utf-8
with:
:set fencs=utf-8,latin1
:%!iconv -f latin1 -t utf-8

Vim might recognize the utf-8 encoding, if not set set 'fenc':
:set fenc=utf8

Hopefully that works.

--
You can be stopped by the police for biking over 65 miles per hour.
You are not allowed to walk across a street on your hands.
[real standing laws in Connecticut, United States of America]

/// Bram Moolenaar -- Bram@Moolenaar.net -- 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_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/202012081255.0B8CtN671630556%40masaka.moolenaar.net.

No comments: