Loading ...
Sorry, an error occurred while loading the content.

Editing files with native characters in their names?

Expand Messages
  • Valery Kondakoff
    Hello, vim-developers! It seems, currently it is impossible to edit files with native characters in their names, when GVIM enoding is set to UTF-8. (WinXP,
    Message 1 of 5 , May 5 7:10 AM
    • 0 Attachment
      Hello, vim-developers!

      It seems, currently it is impossible to edit files with native
      characters in their names, when GVIM enoding is set to UTF-8. (WinXP,
      GVIM 6.1 1-449)

      There is an example: it is possible to open such a file with GVIM
      internal File Explorer or by using 'File - Open' menu item, but the
      name of the file will be damaged, so it will be impossible to write it
      back. The name of the file looks like this after opening in GVIM:
      '<f2><ee><e2><fb><e9>.txt'.

      And it is completely impossible to open a file with native characters
      in the name using ':e' command or from command line - GVIM just does
      not found a file and opens an empty file with damaged name.

      More details: the default Russian character encoding under Windows is
      CP1251. So, the filenames with Russian characters are stored in this
      encoding. There are my GVIM language settings:

      set encoding=utf-8
      set fileencoding=cp1251
      set fileencodings=cp1251,cp866,koi8-r,latin1

      If there is something we can do about this? Thank you.


      --
      Best regards,
      Valery Kondakoff
      http://www.nbk.orc.ru (Ne Bey Kopytom)
      http://www.nbk.orc.ru/mtb (MTB riding in Moscow)

      PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...
    • Bram Moolenaar
      ... Hmm, does this mean we need to convert between wide characters and utf-8 for all the functions that use file names? I thought this already worked, since I
      Message 2 of 5 , May 5 10:54 AM
      • 0 Attachment
        Valery Kondakoff wrote:

        > Hello, vim-developers!
        >
        > It seems, currently it is impossible to edit files with native
        > characters in their names, when GVIM enoding is set to UTF-8. (WinXP,
        > GVIM 6.1 1-449)
        >
        > There is an example: it is possible to open such a file with GVIM
        > internal File Explorer or by using 'File - Open' menu item, but the
        > name of the file will be damaged, so it will be impossible to write it
        > back. The name of the file looks like this after opening in GVIM:
        > '<f2><ee><e2><fb><e9>.txt'.
        >
        > And it is completely impossible to open a file with native characters
        > in the name using ':e' command or from command line - GVIM just does
        > not found a file and opens an empty file with damaged name.
        >
        > More details: the default Russian character encoding under Windows is
        > CP1251. So, the filenames with Russian characters are stored in this
        > encoding. There are my GVIM language settings:
        >
        > set encoding=utf-8
        > set fileencoding=cp1251
        > set fileencodings=cp1251,cp866,koi8-r,latin1
        >
        > If there is something we can do about this? Thank you.

        Hmm, does this mean we need to convert between wide characters and utf-8
        for all the functions that use file names?

        I thought this already worked, since I fixed a few things for Asian file
        names in the past. But perhaps it only works for DBCS, not for utf-8?

        --
        hundred-and-one symptoms of being an internet addict:
        172. You join listservers just for the extra e-mail.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
      • Ron Aaron
        ... I just verified this on XP. If you drag such a file to vim, it comes up as ???? instead of the file name. If you do :e and try tab-completion, the file
        Message 3 of 5 , May 5 11:04 AM
        • 0 Attachment
          > >
          > > If there is something we can do about this? Thank you.
          >
          > Hmm, does this mean we need to convert between wide
          > characters and utf-8
          > for all the functions that use file names?
          >
          > I thought this already worked, since I fixed a few things for
          > Asian file
          > names in the past. But perhaps it only works for DBCS, not for utf-8?


          I just verified this on XP.

          If you drag such a file to vim, it comes up as ???? instead of the file name.

          If you do :e and try tab-completion, the file does not show up in the list of matches.
        • Bram Moolenaar
          ... I suppose this means that filenames are in the active codepage encoding. We should convert them to encoding to be able to display them properly.
          Message 4 of 5 , May 5 11:38 AM
          • 0 Attachment
            Ron Aaron wrote:

            > > Hmm, does this mean we need to convert between wide characters and
            > > utf-8 for all the functions that use file names?
            > >
            > > I thought this already worked, since I fixed a few things for Asian
            > > file names in the past. But perhaps it only works for DBCS, not for
            > > utf-8?
            >
            > I just verified this on XP.
            >
            > If you drag such a file to vim, it comes up as ???? instead of the
            > file name.

            I suppose this means that filenames are in the "active codepage"
            encoding. We should convert them to 'encoding' to be able to display
            them properly. However, it should still be possible to read and write
            the file, using the filename as a sequence of bytes.

            This would be quite a lot of work to implement. Either converting the
            name for every system function, or converting the name every time it is
            used in Vim.

            > If you do :e and try tab-completion, the file does not show up in the
            > list of matches.

            Strange, I would expect the ???? entries to show up. Is there some
            magic going on here?

            --
            hundred-and-one symptoms of being an internet addict:
            174. You know what a listserv is.

            /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
            /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
            \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
            \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///
          • Tony Mechelynck
            ... There ought to be something better, but just as a makeshift temporary solution, which I believe could be automated by means of a .BAT file (the actual
            Message 5 of 5 , May 5 3:16 PM
            • 0 Attachment
              Valery Kondakoff <strauss@...> wrote:
              > Hello, vim-developers!
              >
              > It seems, currently it is impossible to edit files with native
              > characters in their names, when GVIM enoding is set to UTF-8. (WinXP,
              > GVIM 6.1 1-449)
              >
              > There is an example: it is possible to open such a file with GVIM
              > internal File Explorer or by using 'File - Open' menu item, but the
              > name of the file will be damaged, so it will be impossible to write it
              > back. The name of the file looks like this after opening in GVIM:
              > '<f2><ee><e2><fb><e9>.txt'.
              >
              > And it is completely impossible to open a file with native characters
              > in the name using ':e' command or from command line - GVIM just does
              > not found a file and opens an empty file with damaged name.
              >
              > More details: the default Russian character encoding under Windows is
              > CP1251. So, the filenames with Russian characters are stored in this
              > encoding. There are my GVIM language settings:
              >
              > set encoding=utf-8
              > set fileencoding=cp1251
              > set fileencodings=cp1251,cp866,koi8-r,latin1
              >
              > If there is something we can do about this? Thank you.
              >
              >
              > --
              > Best regards,
              > Valery Kondakoff
              > http://www.nbk.orc.ru (Ne Bey Kopytom)
              > http://www.nbk.orc.ru/mtb (MTB riding in Moscow)
              >
              > PGP key:
              > mailto:pgp-public-keys@...?subject=GET%20strauss@...

              There ought to be something better, but just as a makeshift temporary
              solution, which I believe could be automated by means of a .BAT file (the
              actual writing of it is left as an exercise to the reader ha ha):

              (a) Copy or rename to a non-yet-existing ASCII name (either a "temporary
              workfile name", guaranteed by the OS to be unique, or a user-chosen name
              which will not be used for any permanent file -- maybe something like
              GVIMDATA.$$$ or maybe even GVIMWORK.001, GVIMWORK.002 etc., testing for "IF
              EXIST" and using only if it doesn't)

              (b) If (a) succeeds, edit the file under the name just created

              (c) If (b) succeeds, rename back to the original name.

              (d) If any of the above does *not* succeed (ERRORLEVEL too high), give
              (ECHO) an error message describing the error.

              Vsyevo khoroshevo,
              Tony.
            Your message has been successfully submitted and would be delivered to recipients shortly.