Thursday, April 9, 2015

Re: How to convert plain text from code page Windows 1250 to code page ISO 8859-2?

On Thursday, April 9, 2015 at 7:03:53 AM UTC-5, Igor Forca wrote:
> Ben,
>
> For step 4:
> :set fileencoding=cp28592
> solves the problem.
>
> It is little bit strange to me that iso-8859-2 has to be written as cp28592 in Vim, but on the other hand "utf-8" is perfectly valid code page name in Vim. I would expect consistency in this case UTF-8 code page written as cp65001 and so not excepting "utf-8" name - see Windows code pages: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx
>
> But I would prefer to have the same names on both Vim for Linux and Vim for Windows. I have some vimscripts and as I see I will have to have two scripts one for each operating system, I an not very happy about this.
>
> Thanks a lot.

You can still share a script. First, you could try the cp28592 encoding on Linux, possibly with the "8bit" prefix, i.e. "8bit-cp28592".

If that doesn't work or you don't like it, you can determine the OS in your script:

if has('win32')
setl fenc=cp28592
else
setl fenc=iso-8859-2
endif

Finally, I think the reason the ISO-8859 name doesn't work, is that Vim on Linux is using the iconv library to do the conversion, and on Windows it is using Windows built-ins for the conversion, which accept codepage names instead.

I think it is possible to get Vim on Windows to use an iconv.dll library. I'm not sure exactly how it will work, but if you do that you could probably use the canonical name. See :help iconv-dynamic. You'll need to find an iconv library compiled for Windows.

--
--
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: