OSDN Git Service

keep JIS level 3 Kanjis if encode_fallback is specified [nkf-bug#36572]
authorNARUSE, Yui <naruse@users.sourceforge.jp>
Tue, 24 Jan 2017 04:39:00 +0000 (13:39 +0900)
committerNARUSE, Yui <naruse@users.sourceforge.jp>
Tue, 24 Jan 2017 04:42:14 +0000 (13:42 +0900)
nkf.c
nkf_test.pl

diff --git a/nkf.c b/nkf.c
index b58c437..8d02923 100644 (file)
--- a/nkf.c
+++ b/nkf.c
@@ -1947,12 +1947,17 @@ unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *p2, nkf_c
        ret = unicode_to_jis_common2(c1, c0, ppp[c2 - 0xE0], sizeof_utf8_to_euc_C2, p2, p1);
     }else return -1;
 #ifdef SHIFTJIS_CP932
-    if (!ret && !cp932inv_f && is_eucg3(*p2)) {
-       nkf_char s2, s1;
-       if (e2s_conv(*p2, *p1, &s2, &s1) == 0) {
-           s2e_conv(s2, s1, p2, p1);
-       }else{
-           ret = 1;
+    if (!ret&& is_eucg3(*p2)) {
+       if (cp932inv_f) {
+           if (encode_fallback) ret = 1;
+       }
+       else {
+           nkf_char s2, s1;
+           if (e2s_conv(*p2, *p1, &s2, &s1) == 0) {
+               s2e_conv(s2, s1, p2, p1);
+           }else{
+               ret = 1;
+           }
        }
     }
 #endif
index 4e5a1fb..f9e1e07 100644 (file)
@@ -1369,6 +1369,11 @@ printf "%-40s",  "[nkf-bug:32328] JIS";
     "\x1b\x1b\$B\$\x22\x1b(B",
     "\x1b\xe3\x81\x82");
 
+printf "%-40s",  "[nkf-bug:36572]";
+    &test("$nkf -sW --fb-html",
+    "\xe6\xbf\xb9\xe4\xb8\x8a",
+    "&#28665;\x8f\xe3");
+
     if (!NKF) {
 printf "%-40s", "Guess NL";
 &command_tests(