Sunday, January 31, 2016

Re: Can you edit EBCDIC files on non-OS390 builds of VIM?

On Sun, Jan 31, 2016 at 3:32 AM, Justin Dearing <zippy1981@gmail.com> wrote:
> I'd like to edit EBCDIC encoded files in VIM on windows vim --version shows this:
>
> VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep 16 2015 08:44:57)
> Included patches: 1-872
> Compiled by <alexpux@gmail.com>
> Huge version without GUI. Features included (+) or not (-):
> <snip/>
> -ebcdic +mouse +smartindent -xim
> <snip/>
>
> I cloned the git repo and configure --enable-ebcdic was not an option. Looking at src/auto/configure, it looks like ebcdic support is enabled if ASCII support is not present. Is there an option to turn it on?
>

IIUC, +ebcdic means "compiled on an EBCDIC machine", IOW, the Vim
_source_ was in EBCDIC. In order to edit EBCDIC _data_ files it is
enough to have a Vim which can thanslate the data losslessly back and
forth between the file's 'fileencoding' (i.e. the charset the file
uses on disk) and Vim's 'encoding' (i.e. the charset Vim uses in
memory, for which UTF-8 is the recommended value).

I expect that any Vim compiled with +iconv (or with +iconv/dyn with
the iconv or libiconv library found at runtime) should be able to edit
such files _provided_ that their 'fileencoding' be recognized when the
time comes to edit them. One of the possible ways is to tell Vim the
'fileencoding' when loading the file in order to edit it. See:
iconv --list
:help ++opt
http://vim.wikia.com/wiki/Working_with_Unicode

The first of these tells you which charsets are known to the iconv
program installed on your system (There are usually very many, so you
may want to filter the output though the less pager, or even through
"view -" without quotes). The second one tells you how to tell Vim the
charset of a given editfile. The third is general information about
using Vim for editing files not all in the same charset, by setting
Vim to use Unicode internally so any charset can be translated
losslessly to and from the one used internally by Vim.

Example:
:new ++enc=ebcdic-us /path/to/filename.ext

will edit the file in a new window and translate it from EBCDIC(US) to
Vim's 'encoding' (e.g. to UTF-8) when reading; when comes the time to
save your edited file, the opposite translation will happen.


Best regards,
Tony.

--
--
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.
For more options, visit https://groups.google.com/d/optout.

No comments: