I revised the patch.
"shift-jisx0213", "euc-jisx0213" and "euc-jp-ms" are moved from 
enc_alias_table[] to enc_canon_table[].

Thanks,
fujiwara

(07/22/09 00:20), Takao Fujiwara-san wrote:
> (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
-~----------~----~----~----~------~----~------~--~---

--- vim72/src/mbyte.c.orig      2009-07-08 16:32:29.000000000 +0900
+++ vim72/src/mbyte.c   2009-07-22 09:14:00.000000000 +0900
@@ -315,7 +315,13 @@ enc_canon_table[] =
     {"dec-mcs",                ENC_8BIT,               0},     /* DEC MCS */
 #define IDX_HPROMAN8   59
     {"hp-roman8",      ENC_8BIT,               0},     /* HP Roman8 */
-#define IDX_COUNT      60
+#define IDX_SJISX0213  60
+    {"shift-jisx0213", ENC_DBCS,               DBCS_JPN},
+#define IDX_EUCJISX0213        61
+    {"euc-jisx0213",   ENC_DBCS,               DBCS_JPNU},
+#define IDX_EUC_JP_MS  62
+    {"euc-jp-ms",      ENC_DBCS,               DBCS_JPNU},
+#define IDX_COUNT      63
 };
 
 /*
@@ -367,6 +373,11 @@ enc_alias_table[] =
     {"utf32le",                IDX_UCS4LE},
     {"utf-32le",       IDX_UCS4LE},
     {"932",            IDX_CP932},
+    {"ms932",          IDX_CP932},
+    {"windows-31j",    IDX_CP932},
+    {"cswindows31j",   IDX_CP932},
+    {"sjis-win",       IDX_CP932},
+    {"sjis-open",      IDX_CP932},
     {"949",            IDX_CP949},
     {"936",            IDX_CP936},
     {"gbk",            IDX_CP936},
@@ -374,7 +385,15 @@ enc_alias_table[] =
     {"eucjp",          IDX_EUC_JP},
     {"unix-jis",       IDX_EUC_JP},
     {"ujis",           IDX_EUC_JP},
+    {"cseucpkdfmtjapanese",    IDX_EUC_JP},
+    {"osf00030010",    IDX_EUC_JP},
+    {"eucjp-ms",       IDX_EUC_JP_MS},
+    {"eucjp-open",     IDX_EUC_JP_MS},
+    {"eucjp-win",      IDX_EUC_JP_MS},
     {"shift-jis",      IDX_SJIS},
+    {"csshiftjis",     IDX_SJIS},
+    {"ms-kanji",       IDX_SJIS},
+    {"pck",            IDX_SJIS},
     {"euckr",          IDX_EUC_KR},
     {"5601",           IDX_EUC_KR},    /* Sun: KS C 5601 */
     {"euccn",          IDX_EUC_CN},
@@ -396,6 +415,7 @@ enc_alias_table[] =
     {"cp950",          IDX_BIG5},
     {"950",            IDX_BIG5},
 #endif
+    {"ansi-1251",      IDX_CP1251},
     {"mac",            IDX_MACROMAN},
     {"mac-roman",      IDX_MACROMAN},
     {NULL,             0}

Raspunde prin e-mail lui