aboutsummaryrefslogtreecommitdiffstats
path: root/debian/patches/190_codepage.patch
blob: 8e30d05f88d140a06efe3e7817587ef86d196cd0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
Description: Handling of codepage with wc_codepage
 * [w3m-dev 04279] charset
 * libwc/ces.h, libwc/charset.c: set charset to Shift_JIS, when locale 
   is japanese, jp_JP.PCK, ja_JP.IBM-932, ja_JP.IBM-943, or windows-31j.
Origin: upstream, http://w3m.cvs.sourceforge.net/viewvc/w3m/w3m/
Author: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>

diff -urN w3m-0.5.2.orig/libwc/ces.h w3m/libwc/ces.h
--- w3m-0.5.2.orig/libwc/ces.h	2003-09-23 06:02:23.000000000 +0900
+++ w3m/libwc/ces.h	2007-06-07 19:59:52.000000000 +0900
@@ -176,6 +176,7 @@
 
 #define WC_CES_SHIFT_JIS	(WC_CES_E_PRIV2|WC_CES_N_SHIFT_JIS)
 #define WC_CES_CP932		WC_CES_SHIFT_JIS
+#define WC_CES_CP943		WC_CES_SHIFT_JIS
 #define WC_CES_SHIFT_JISX0213	(WC_CES_E_PRIV2|WC_CES_N_SHIFT_JISX0213)
 #define WC_CES_GBK		(WC_CES_E_PRIV2|WC_CES_N_GBK)
 #define WC_CES_CP936		WC_CES_GBK
diff -urN w3m-0.5.2.orig/libwc/charset.c w3m/libwc/charset.c
--- w3m-0.5.2.orig/libwc/charset.c	2007-05-23 21:34:20.000000000 +0900
+++ w3m/libwc/charset.c	2007-06-07 19:59:52.000000000 +0900
@@ -32,6 +32,46 @@
   { NULL, 0 }
 };
 
+static wc_ces
+wc_codepage(int n)
+{
+	switch (n) {
+	case 437: return WC_CES_CP437;
+	case 737: return WC_CES_CP737;
+	case 775: return WC_CES_CP775;
+	case 850: return WC_CES_CP850;
+	case 852: return WC_CES_CP852;
+	case 855: return WC_CES_CP855;
+	case 856: return WC_CES_CP856;
+	case 857: return WC_CES_CP857;
+	case 860: return WC_CES_CP860;
+	case 861: return WC_CES_CP861;
+	case 862: return WC_CES_CP862;
+	case 863: return WC_CES_CP863;
+	case 864: return WC_CES_CP864;
+	case 865: return WC_CES_CP865;
+	case 866: return WC_CES_CP866;
+	case 869: return WC_CES_CP869;
+	case 874: return WC_CES_CP874;
+	case 932: return WC_CES_CP932;		/* CP932 = Shift_JIS */
+	case 936: return WC_CES_CP936;		/* CP936 = GBK > EUC_CN */
+	case 943: return WC_CES_CP943;		/* CP943 = Shift_JIS */
+	case 949: return WC_CES_CP949;		/* CP949 = UHC > EUC_KR */
+	case 950: return WC_CES_CP950;		/* CP950 = Big5 */
+	case 1006: return WC_CES_CP1006;
+	case 1250: return WC_CES_CP1250;
+	case 1251: return WC_CES_CP1251;
+	case 1252: return WC_CES_CP1252;
+	case 1253: return WC_CES_CP1253;
+	case 1254: return WC_CES_CP1254;
+	case 1255: return WC_CES_CP1255;
+	case 1256: return WC_CES_CP1256;
+	case 1257: return WC_CES_CP1257;
+	case 1258: return WC_CES_CP1258;
+	}
+	return 0;
+}
+
 wc_ces
 wc_guess_charset(char *charset, wc_ces orig)
 {
@@ -119,6 +159,11 @@
 	    if (n >= 1 && n <= 16 && n != 12)
 		return (WC_CES_E_ISO_8859 | n);
 	    return WC_CES_ISO_8859_1;
+	} else if (! strncmp(p, "ibm", 3)) {
+	    p += 3;
+	    if (*p >= '1' && *p <= '9')
+	    	return wc_codepage(atoi(p));
+	    return wc_charset_to_ces(p);
 	}
 	break;
     case 'j':
@@ -135,6 +180,10 @@
 	    ! strncmp(p, "sjis", 4))
 	    return WC_CES_SHIFT_JIS;
 	break;
+    case 'p':
+	if (! strncmp(p, "pck", 3))
+	    return WC_CES_SHIFT_JIS;
+	break;
     case 'g':
 	if (! strncmp(p, "gb18030", 7) ||
 	    ! strncmp(p, "gbk2k", 5))
@@ -210,58 +259,18 @@
 	    return WC_CES_EUC_CN;
 	if (*(p+1) != 'p')
 	    break;
-	n = atoi(p + 2);
-	switch (n) {
-	case 437: return WC_CES_CP437;
-	case 737: return WC_CES_CP737;
-	case 775: return WC_CES_CP775;
-	case 850: return WC_CES_CP850;
-	case 852: return WC_CES_CP852;
-	case 855: return WC_CES_CP855;
-	case 856: return WC_CES_CP856;
-	case 857: return WC_CES_CP857;
-	case 860: return WC_CES_CP860;
-	case 861: return WC_CES_CP861;
-	case 862: return WC_CES_CP862;
-	case 863: return WC_CES_CP863;
-	case 864: return WC_CES_CP864;
-	case 865: return WC_CES_CP865;
-	case 866: return WC_CES_CP866;
-	case 869: return WC_CES_CP869;
-	case 874: return WC_CES_CP874;
-	case 932: return WC_CES_CP932;		/* CP932 = Shift_JIS */
-	case 936: return WC_CES_CP936;		/* CP936 = GBK > EUC_CN */
-	case 949: return WC_CES_CP949;		/* CP949 = UHC > EUC_KR */
-	case 950: return WC_CES_CP950;		/* CP950 = Big5 */
-	case 1006: return WC_CES_CP1006;
-	case 1250: return WC_CES_CP1250;
-	case 1251: return WC_CES_CP1251;
-	case 1252: return WC_CES_CP1252;
-	case 1253: return WC_CES_CP1253;
-	case 1254: return WC_CES_CP1254;
-	case 1255: return WC_CES_CP1255;
-	case 1256: return WC_CES_CP1256;
-	case 1257: return WC_CES_CP1257;
-	case 1258: return WC_CES_CP1258;
-	}
+	p += 2;
+	if (*p >= '1' &&  *p <= '9')
+	    return wc_codepage(atoi(p));
 	break;
     case 'w':
 	if (strncmp(p, "windows", 7))
 	    break;
+	p += 7;
 	if (! strncmp(p, "31j", 3))
 	    return WC_CES_CP932;
-	n = atoi(p + 7);
-	switch (n) {
-	case 1250: return WC_CES_CP1250;
-	case 1251: return WC_CES_CP1251;
-	case 1252: return WC_CES_CP1252;
-	case 1253: return WC_CES_CP1253;
-	case 1254: return WC_CES_CP1254;
-	case 1255: return WC_CES_CP1255;
-	case 1256: return WC_CES_CP1256;
-	case 1257: return WC_CES_CP1257;
-	case 1258: return WC_CES_CP1258;
-	}
+	if (*p >= '1' &&  *p <= '9')
+	    return wc_codepage(atoi(p));
 	break;
     }
     return 0;
@@ -345,18 +354,9 @@
     case 'c':
 	return WC_CES_ISO_2022_CN;
     case 'w':
-	n = atoi(p + 1);
-	switch (n) {
-	case 1250: return WC_CES_CP1250;
-	case 1251: return WC_CES_CP1251;
-	case 1252: return WC_CES_CP1252;
-	case 1253: return WC_CES_CP1253;
-	case 1254: return WC_CES_CP1254;
-	case 1255: return WC_CES_CP1255;
-	case 1256: return WC_CES_CP1256;
-	case 1257: return WC_CES_CP1257;
-	case 1258: return WC_CES_CP1258;
-	}
+	p++;
+	if (*p >= '1' &&  *p <= '9')
+	    return wc_codepage(atoi(p));
 	break;
     case 'r':
 	return WC_CES_RAW;
@@ -368,7 +368,7 @@
 wc_locale_to_ces(char *locale)
 {
     char *p = locale;
-    char buf[6];
+    char buf[8];
     int n;
 
     if (*p == 'C' && *(p+1) == '\0')
@@ -380,7 +380,7 @@
 	    return wc_charset_to_ces(cs);
     }
 #endif
-    for (n = 0; *p && *p != '.' && n < 5; p++) {
+    for (n = 0; *p && *p != '.' && n < 7; p++) {
 	if ((unsigned char)*p > 0x20)
 	    buf[n++] = tolower(*p);
     }