Conversion Error

18 views
Skip to first unread message

Robert Solomon

unread,
Jul 18, 2021, 9:18:36 AM7/18/21
to vim_use
I often copy-paste from a browser into a text file to save the content I come across.  When I try to save the file, I often get a conversion error.  I have to manually go thru each error and change the extended character to an ascii one.

I don't understand why this happens.  Any file I see is saved on a server, so why can't vim also save that file? 
And, what do I do to automatically save the file?

Thx,
Rob

Robert Solomon

unread,
Jul 18, 2021, 4:33:32 PM7/18/21
to vim_use
I forgot to add that this is on a Windows 10 computer running gvim 8.2 w/ patches including 3049.

Eike Rathke

unread,
Jul 18, 2021, 5:10:38 PM7/18/21
to vim...@googlegroups.com
Hi Robert,

On Sunday, 2021-07-18 06:18:36 -0700, Robert Solomon wrote:

> I often copy-paste from a browser into a text file to save the content I
> come across. When I try to save the file, I often get a conversion error.
> I have to manually go thru each error and change the extended character to
> an ascii one.

Likely the text pasted from clipboard is in a different text encoding
(usually UTF-16 on Windows) than the file is saved in, and the file's
text encoding can't represent all characters. Issue the command

:set fenc?

that displays the current fileencoding. To be on the safe side choose an
encoding that can represent all Unicode characters, common is UTF-8.

So,

:set fileencoding=utf-8

before saving.

Best have encoding (taken from current locale) and fileencoding aligned
set to utf-8, but things may be more complicated on Windows. See
https://vim.fandom.com/wiki/Working_with_Unicode and the help sections
it references.

Eike

--
OpenPGP/GnuPG encrypted mail preferred in all private communication.
GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918 630B 6A6C D5B7 6563 2D3A
Use LibreOffice! https://www.libreoffice.org/
signature.asc

rob

unread,
Jul 18, 2021, 7:07:36 PM7/18/21
to vim...@googlegroups.com
> Hi Robert,
>
> On Sunday, 2021-07-18 06:18:36 -0700, Robert Solomon wrote:
>
>> I often copy-paste from a browser into a text file to save the content I
>> come across. When I try to save the file, I often get a conversion error.
>> I have to manually go thru each error and change the extended character to
>> an ascii one.
> Likely the text pasted from clipboard is in a different text encoding
> (usually UTF-16 on Windows) than the file is saved in, and the file's
> text encoding can't represent all characters. Issue the command
>
> :set fenc?
>
> that displays the current fileencoding. To be on the safe side choose an
> encoding that can represent all Unicode characters, common is UTF-8.
>
> So,
>
> :set fileencoding=utf-8
>
> before saving.
>
> Best have encoding (taken from current locale) and fileencoding aligned
> set to utf-8, but things may be more complicated on Windows. See
> https://vim.fandom.com/wiki/Working_with_Unicode and the help sections
> it references.
>
> Eike
>

Hi Eike,

I think that was it.  It seems that the fenc for my files is latin1. 
I'll add a line in my _vimrc to set fenc=utf-8

Thanks

--rob

Reply all
Reply to author
Forward
0 new messages