Revision | c9c993ffc2b617083c82b701495ce2143be5232e (tree) |
---|---|
Time | 2018-12-15 17:22:47 |
Author | NARUSE, Yui <naruse@user...> |
Commiter | NARUSE, Yui |
--fb-java doesn't follow java's spec
Though --fb-java's name insista Java's behavior but it behaved as
what Python does. [nkf-bug:38800]
@@ -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 |
@@ -1353,6 +1353,11 @@ printf "%-40s", "[nkf-forum:65482] "; | ||
1353 | 1353 | "\x1b\x24\x42\x7f\x21\x80\x21\x1b\x28\x42\n", |
1354 | 1354 | "\xf0\x40\xf0\x9f\x0a"); |
1355 | 1355 | |
1356 | +printf "%-40s", "[nkf-bug:38800] "; | |
1357 | + &test("$nkf -W -e --fb-java", | |
1358 | + "\xF0\xA0\xAE\xB7", | |
1359 | + "\\uD842\\uDFB7"); | |
1360 | + | |
1356 | 1361 | # [KNOWNBUG] |
1357 | 1362 | # printf "%-40s", "[ruby-dev:47057] "; |
1358 | 1363 | # &test("$nkf -jW -M --cp932", |