|
1 | 1 | /*
|
2 | 2 | * Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
|
3 |
| - * Copyright (c) 1996-2013, The nkf Project. |
| 3 | + * Copyright (c) 1996-2018, The nkf Project. |
4 | 4 | *
|
5 | 5 | * This software is provided 'as-is', without any express or implied
|
6 | 6 | * warranty. In no event will the authors be held liable for any damages
|
|
20 | 20 | *
|
21 | 21 | * 3. This notice may not be removed or altered from any source distribution.
|
22 | 22 | */
|
23 |
| -#define NKF_VERSION "2.1.4" |
24 |
| -#define NKF_RELEASE_DATE "2015-12-12" |
| 23 | +#define NKF_VERSION "2.1.5" |
| 24 | +#define NKF_RELEASE_DATE "2018-12-15" |
25 | 25 | #define COPY_RIGHT \
|
26 | 26 | "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).\n" \
|
27 |
| - "Copyright (C) 1996-2015, The nkf Project." |
| 27 | + "Copyright (C) 1996-2018, The nkf Project." |
28 | 28 |
|
29 | 29 | #include "config.h"
|
30 | 30 | #include "nkf.h"
|
@@ -1111,18 +1111,26 @@ encode_fallback_java(nkf_char c)
|
1111 | 1111 | (*oconv)(0, '\\');
|
1112 | 1112 | c &= VALUE_MASK;
|
1113 | 1113 | if(!nkf_char_unicode_bmp_p(c)){
|
1114 |
| - (*oconv)(0, 'U'); |
1115 |
| - (*oconv)(0, '0'); |
1116 |
| - (*oconv)(0, '0'); |
1117 |
| - (*oconv)(0, bin2hex(c>>20)); |
1118 |
| - (*oconv)(0, bin2hex(c>>16)); |
| 1114 | + int high = (c >> 10) + NKF_INT32_C(0xD7C0); /* high surrogate */ |
| 1115 | + int low = (c & 0x3FF) + NKF_INT32_C(0xDC00); /* low surrogate */ |
| 1116 | + (*oconv)(0, 'u'); |
| 1117 | + (*oconv)(0, bin2hex(high>>12)); |
| 1118 | + (*oconv)(0, bin2hex(high>> 8)); |
| 1119 | + (*oconv)(0, bin2hex(high>> 4)); |
| 1120 | + (*oconv)(0, bin2hex(high )); |
| 1121 | + (*oconv)(0, '\\'); |
| 1122 | + (*oconv)(0, 'u'); |
| 1123 | + (*oconv)(0, bin2hex(low>>12)); |
| 1124 | + (*oconv)(0, bin2hex(low>> 8)); |
| 1125 | + (*oconv)(0, bin2hex(low>> 4)); |
| 1126 | + (*oconv)(0, bin2hex(low )); |
1119 | 1127 | }else{
|
1120 | 1128 | (*oconv)(0, 'u');
|
| 1129 | + (*oconv)(0, bin2hex(c>>12)); |
| 1130 | + (*oconv)(0, bin2hex(c>> 8)); |
| 1131 | + (*oconv)(0, bin2hex(c>> 4)); |
| 1132 | + (*oconv)(0, bin2hex(c )); |
1121 | 1133 | }
|
1122 |
| - (*oconv)(0, bin2hex(c>>12)); |
1123 |
| - (*oconv)(0, bin2hex(c>> 8)); |
1124 |
| - (*oconv)(0, bin2hex(c>> 4)); |
1125 |
| - (*oconv)(0, bin2hex(c )); |
1126 | 1134 | return;
|
1127 | 1135 | }
|
1128 | 1136 |
|
@@ -1947,12 +1955,17 @@ unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *p2, nkf_c
|
1947 | 1955 | ret = unicode_to_jis_common2(c1, c0, ppp[c2 - 0xE0], sizeof_utf8_to_euc_C2, p2, p1);
|
1948 | 1956 | }else return -1;
|
1949 | 1957 | #ifdef SHIFTJIS_CP932
|
1950 |
| - if (!ret && !cp932inv_f && is_eucg3(*p2)) { |
1951 |
| - nkf_char s2, s1; |
1952 |
| - if (e2s_conv(*p2, *p1, &s2, &s1) == 0) { |
1953 |
| - s2e_conv(s2, s1, p2, p1); |
1954 |
| - }else{ |
1955 |
| - ret = 1; |
| 1958 | + if (!ret&& is_eucg3(*p2)) { |
| 1959 | + if (cp932inv_f) { |
| 1960 | + if (encode_fallback) ret = 1; |
| 1961 | + } |
| 1962 | + else { |
| 1963 | + nkf_char s2, s1; |
| 1964 | + if (e2s_conv(*p2, *p1, &s2, &s1) == 0) { |
| 1965 | + s2e_conv(s2, s1, p2, p1); |
| 1966 | + }else{ |
| 1967 | + ret = 1; |
| 1968 | + } |
1956 | 1969 | }
|
1957 | 1970 | }
|
1958 | 1971 | #endif
|
|
0 commit comments