(07/21/09 19:09), Tony Mechelynck-san wrote:
> On 21/07/09 10:04, Takao Fujiwara wrote:
>> (07/21/09 16:34), Tony Mechelynck-san wrote:
>>> Mine could, obviously, and without any patching.
>>
>> Your suggestion doesn't work on none UTF-8 in my env.
>>
>> 1. Launch your terminal on ja_JP.WINDOWS-31J
>> % iconv -f eucJP -t WINDOWS-31j pkdfmt.txt > pkdfmt-win31j.txt
>> % vim
>> :view ++enc=windows-31j pkdfmt-win31j.txt
>>
>> It doesn't work on WINDOWS-31J encoding but it works on UTF-8.
>>
>
> Hm. I produced the attached file using gvim, as follows:
>
> :sv ++enc=cseucpkdfmtjapanese pkdfmt.txt
> :sav ++enc=windows-31j ~/win31j.txt
> :q
>
> What do(es) your Vim executable(s) answer to
>
> :echo has('iconv')
>
> ? I wonder if maybe something went wrong.

It returns 1.

>
> FWIW, my gvim has 'encoding' set to utf-8, and I never change my
> terminal's locale, where
>
> $LANG=en_US.UTF-8
> $LC_ALL and $LC_CTYPE are both unset.
>
> In gvim, ":lang" answers
> Current language:
> "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=en_US.UTF-8;LC_TIME=en_GB;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=C;LC_PAPER=en_GB;LC_NAME=en_US.UTF-8;LC_ADDRESS=en_US.UTF-8;LC_TELEPHONE=en_US.UTF-8;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=en_US.UTF-8"

As I explained, it works on UTF-8.
The problem is that the current locale is not in the vim table.

Please let me explain the source codes.
When you invoke ":view ++enc=windows-31j foo.txt", 
"vim7/src/fileio.c:"readfile() is called.
readfile() calls my_iconv_open() at line 9886 "fileio.c".
my_iconv_open() sends p_enc for the from encoding.
p_enc = "latin1"

The current locale is ja_JP.WINDOWS-31J but the problem is the vim sets the 
p_enc = "latin1".
p_enc is decided in "vim7/src/option.c:"set_init_1().
set_init_1() calls enc_locale() and enc_locale() returns "windows-31j".
set_init_1() calls mb_init().
But mb_init() returns error string.
So set_init_1() sets p_enc = "latin1" at line 3389 "option.c".

mb_init() calls enc_canon_search().

After I apply my patch, enc_locale() returns "cp932" because enc_locale() calls 
the alias table.
And then mb_init() returns NULL and p_enc = "cp932".

I.e. the problem can be reproduce when you run vim on the none UTF-8 locale 
whose encoding doesn't exist in the vim alias table.

On the other hand, whenever you run vim on UTF-8 locale, your ":view 
++enc=windows-31j" should works.
Users request to run vim on such a locale.

Thanks,
fujiwara

>
>
>
>
> Best regards,
> Tony.


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui