• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

nkf with conversion between jisx0213 and utf-8


Commit MetaInfo

Revision647dc310ae01e9d1fd199128e29ab0965a040124 (tree)
Time2012-11-11 10:25:34
AuthorKIHARA Hideto <deton@user...>
CommiterKIHARA Hideto

Log Message

Add is_x0213_2_in_x0212() to avoid wrong conversion for jisx0212 chars (ex: cb9a) from utf-8 to euc-jisx0213 without --cp932inv.
But jisx0212 chars are lost without --cp932inv.

Change Summary

Incremental Difference

--- a/nkf.c
+++ b/nkf.c
@@ -1565,13 +1565,26 @@ x0212_unshift(nkf_char c)
15651565 }
15661566 #endif /* X0212_ENABLE */
15671567
1568+static int
1569+is_x0213_2_in_x0212(nkf_char c1)
1570+{
1571+ static const char x0213_2_table[] =
1572+ {0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1};
1573+ int ku = c1 - 0x20;
1574+ if (ku <= 15)
1575+ return x0213_2_table[ku]; /* 1, 3-5, 8, 12-15 */
1576+ if (78 <= ku && ku <= 94)
1577+ return 1;
1578+ return 0;
1579+}
1580+
15681581 static nkf_char
15691582 e2s_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
15701583 {
15711584 nkf_char ndx;
15721585 if (is_eucg3(c2)){
15731586 ndx = c2 & 0x7f;
1574- if (x0213_f){
1587+ if (x0213_f && is_x0213_2_in_x0212(ndx)){
15751588 if((0x21 <= ndx && ndx <= 0x2F)){
15761589 if (p2) *p2 = ((ndx - 1) >> 1) + 0xec - ndx / 8 * 3;
15771590 if (p1) *p1 = c1 + ((ndx & 1) ? ((c1 < 0x60) ? 0x1f : 0x20) : 0x7e);