[vim/vim] French localisation: wrong encoding in `~/.viminfo`. (#8075)

46 views
Skip to first unread message

Romain Lafourcade

unread,
Apr 6, 2021, 7:33:27 AM4/6/21
to vim/vim, Subscribed

Describe the bug
In Vim with french localisation, the localised comments are not properly encoded.

To Reproduce
Detailed steps to reproduce the behavior:

  1. Run $ LANG=fr_FR.UTF-8 vim --clean /tmp/foo.

  2. Do some editing in that file and write it.

  3. Run vim --clean ~/.viminfo.

  4. Move the cursor to line 7.

  5. Behold this trainwreck:

    # 'encoding' dans lequel ce fichier a été écrit
    
    *encoding=utf-8
    
    

    Here are all the problematic lines:

    # Ce fichier viminfo a été généré par Vim 8.2.
    
    # Vous pouvez l'éditer, mais soyez prudent.
    
    # 'encoding' dans lequel ce fichier a été écrit
    
    # Dernières chaînes de substitution :
    
    # Historique ligne de commande (chronologie décroissante) :
    
    # Historique chaîne de recherche (chronologie décroissante) :
    
    # Historique expression (chronologie décroissante) :
    
    # Historique ligne de saisie (chronologie décroissante) :
    
    # Historique Ligne de débogage (chronologie décroissante) :
    
    # Liste de sauts (le plus récent en premier) :
    
    # Historique des marques dans les fichiers (les plus récentes en premier) :
    
    

Expected behavior
The comments should be encoded properly to look like this:

# 'encoding' dans lequel ce fichier a été écrit

*encoding=utf-8

Environment (please complete the following information):

  • Vim version 8.2.2576
  • OS: MacOS 10.14.6
  • Terminal: irrelevant
  • :echo &encoding prints utf-8.

Additional context
The maintainer of the french localisation seems unresponsive.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Tony Mechelynck

unread,
Apr 6, 2021, 8:42:39 AM4/6/21
to vim/vim, Subscribed

Does your 'viminfo' setting include the c flag?

If it doesn't, do you se a difference if you add

set vi+=c

in your vimrc?

Best regards,
Tony.

Romain Lafourcade

unread,
Apr 6, 2021, 8:57:42 AM4/6/21
to vim/vim, Subscribed

No, there is no difference. The current encoding and the one used to write ~/.viminfo are the same, utf-8, so there shouldn't be any difference anyway.

Gabriel Dupras

unread,
Apr 6, 2021, 10:06:12 AM4/6/21
to vim/vim, Subscribed

If you start Vim with --clean, it implies -i NONE, which means the viminfo file is not read nor written. You should modify your first step.

Anyway, I have the same issue with LANG=fr_CA.UTF-8 on Kubuntu 20.10. If I open .viminfo and do :set fileencoding?, it prints latin1. If I open the file with :edit ++enc=utf-8 .viminfo, the text looks fine. I then wrote the file, opened it again, and the encoding was utf-8, as it should.

I also tried creating a new viminfo file with the following steps and the encoding of the file is correctly set to utf-8.

  1. mv .viminfo .viminfo_orig

  2. vim -Nu DEFAULTS /tmp/foo

  3. Edit and write that file. Quit.

  4. vim -Nu DEFAULTS .viminfo

  5. Encoding looks fine.

So how did the viminfo file end up with the latin1 encoding?

Romain Lafourcade

unread,
Apr 6, 2021, 2:03:03 PM4/6/21
to vim/vim, Subscribed

Related: why are all the files under src/po/ in ISO-8859-1 when Vim is supposed to use UTF-8 internally? This is rather confusing.

Bram Moolenaar

unread,
Apr 6, 2021, 3:25:18 PM4/6/21
to vim/vim, Subscribed

Just historic reasons. French fits perfection in latin1 and the file encoding should be recognized automatically.
It saves a few bytes but that is hardly relevant.

Romain Lafourcade

unread,
Apr 6, 2021, 5:11:10 PM4/6/21
to vim/vim, Subscribed

Alright.

After converting ~/.viminfo to UTF-8 via ++enc=utf-8, the comments are no longer improperly encoded.

So I ran a little bissection experiment with a backup of my original ~/.viminfo until I found the culprit:

culprit

The ý is what appears to be forcing the whole buffer to be encoded in latin1, which presumably caused the issue.

Except I never pressed that key during that recording.

I am somewhat used to see those mysterious <80> (0x80) littering my recordings but that 0xfd following a <80> is new to me.

Gabriel Dupras

unread,
Apr 6, 2021, 5:25:14 PM4/6/21
to vim/vim, Subscribed

French fits perfection in latin1

According to this Wikipedia page, it's missing œ, Œ, and Ÿ. The first two are common in French, in words like cœur, sœur, œuf, etc. I think we should switch to UTF-8 for French.

Romain Lafourcade

unread,
Apr 6, 2021, 5:29:07 PM4/6/21
to vim/vim, Subscribed

@ProgMetalSlug you beat me to it.

Bram Moolenaar

unread,
Apr 7, 2021, 4:20:08 AM4/7/21
to vim/vim, Subscribed


Romain Lafourcade wrote:

> Alright.
>
> After converting `~/.viminfo` to UTF-8 via `++enc=utf-8`, the comments are no longer improperly encoded.

>
> So I ran a little bissection experiment with a backup of my original `~/.viminfo` until I found the culprit:
>
> <img width="479" alt="culprit" src="https://user-images.githubusercontent.com/344335/113776149-e1a3e500-9729-11eb-9f1a-cb8ce6eec3e4.png">
>
> The `ý` is what appears to be forcing the whole buffer to be encoded in `latin1`, which presumably caused the issue.
>
> **Except I never pressed that key during that recording.**
>
> I am somewhat used to see those mysterious `<80>` (`0x80`) littering my recordings but that `0xfd` following a `<80>` is new to me.

The viminfo file isn't really a text file, it's better to consider it a
binary file that Vim uses to write and read internal data. As mentioned
in the help "you can edit it, if you're careful". In other words, if
you edit it you might wreck it.

--
hundred-and-one symptoms of being an internet addict:
79. All of your most erotic dreams have a scrollbar at the right side.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Romain Lafourcade

unread,
Apr 7, 2021, 5:11:14 AM4/7/21
to vim/vim, Subscribed

@brammool I am well aware of the risk, which is why I never edited it. I'm not sure why you bring this up.

There was no manual editing involved at all.

Reply all
Reply to author
Forward
0 new messages