27
27
*
28
28
*/
29
29
30
+ /* UHC was introduced by MicroSoft in Windows 95, and is also known as CP949.
31
+ * It is the same as EUC-KR, but with 8,822 additional characters added to
32
+ * complete all the characters in the Johab charset. */
33
+
30
34
#include "mbfilter.h"
31
35
#include "mbfilter_uhc.h"
32
36
#define UNICODE_TABLE_UHC_DEF
@@ -86,19 +90,16 @@ const struct mbfl_convert_vtbl vtbl_wchar_uhc = {
86
90
87
91
#define CK (statement ) do { if ((statement) < 0) return (-1); } while (0)
88
92
89
- /*
90
- * UHC => wchar
91
- */
92
93
int
93
94
mbfl_filt_conv_uhc_wchar (int c , mbfl_convert_filter * filter )
94
95
{
95
96
int c1 , w = 0 , flag = 0 ;
96
97
97
98
switch (filter -> status ) {
98
99
case 0 :
99
- if (c >= 0 && c < 0x80 ) { /* latin */
100
+ if (c >= 0 && c < 0x80 ) { /* latin */
100
101
CK ((* filter -> output_function )(c , filter -> data ));
101
- } else if (c > 0x80 && c < 0xff && c != 0xc9 ) { /* dbcs lead byte */
102
+ } else if (c > 0x80 && c < 0xff && c != 0xc9 ) { /* dbcs lead byte */
102
103
filter -> status = 1 ;
103
104
filter -> cache = c ;
104
105
} else {
@@ -108,27 +109,27 @@ mbfl_filt_conv_uhc_wchar(int c, mbfl_convert_filter *filter)
108
109
}
109
110
break ;
110
111
111
- case 1 : /* dbcs second byte */
112
+ case 1 : /* dbcs second byte */
112
113
filter -> status = 0 ;
113
114
c1 = filter -> cache ;
114
115
115
- if ( c1 >= 0x81 && c1 <= 0xa0 ){
116
+ if (c1 >= 0x81 && c1 <= 0xa0 ) {
116
117
w = (c1 - 0x81 )* 190 + (c - 0x41 );
117
118
if (w >= 0 && w < uhc1_ucs_table_size ) {
118
119
flag = 1 ;
119
120
w = uhc1_ucs_table [w ];
120
121
} else {
121
122
w = 0 ;
122
123
}
123
- } else if ( c1 >= 0xa1 && c1 <= 0xc6 ){
124
+ } else if (c1 >= 0xa1 && c1 <= 0xc6 ) {
124
125
w = (c1 - 0xa1 )* 190 + (c - 0x41 );
125
126
if (w >= 0 && w < uhc2_ucs_table_size ) {
126
127
flag = 2 ;
127
128
w = uhc2_ucs_table [w ];
128
129
} else {
129
130
w = 0 ;
130
131
}
131
- } else if ( c1 >= 0xc7 && c1 <= 0xfe ){
132
+ } else if (c1 >= 0xc7 && c1 <= 0xfe ) {
132
133
w = (c1 - 0xc7 )* 94 + (c - 0xa1 );
133
134
if (w >= 0 && w < uhc3_ucs_table_size ) {
134
135
flag = 3 ;
@@ -137,15 +138,16 @@ mbfl_filt_conv_uhc_wchar(int c, mbfl_convert_filter *filter)
137
138
w = 0 ;
138
139
}
139
140
}
140
- if (flag > 0 ){
141
+
142
+ if (flag > 0 ) {
141
143
if (w <= 0 ) {
142
144
w = (c1 << 8 ) | c ;
143
145
w &= MBFL_WCSPLANE_MASK ;
144
146
w |= MBFL_WCSPLANE_UHC ;
145
147
}
146
148
CK ((* filter -> output_function )(w , filter -> data ));
147
149
} else {
148
- if ((c >= 0 && c < 0x21 ) || c == 0x7f ) { /* CTLs */
150
+ if ((c >= 0 && c < 0x21 ) || c == 0x7f ) { /* CTLs */
149
151
CK ((* filter -> output_function )(c , filter -> data ));
150
152
} else {
151
153
w = (c1 << 8 ) | c ;
@@ -164,15 +166,11 @@ mbfl_filt_conv_uhc_wchar(int c, mbfl_convert_filter *filter)
164
166
return c ;
165
167
}
166
168
167
- /*
168
- * wchar => UHC
169
- */
170
169
int
171
170
mbfl_filt_conv_wchar_uhc (int c , mbfl_convert_filter * filter )
172
171
{
173
- int c1 , s ;
172
+ int c1 , s = 0 ;
174
173
175
- s = 0 ;
176
174
if (c >= ucs_a1_uhc_table_min && c < ucs_a1_uhc_table_max ) {
177
175
s = ucs_a1_uhc_table [c - ucs_a1_uhc_table_min ];
178
176
} else if (c >= ucs_a2_uhc_table_min && c < ucs_a2_uhc_table_max ) {
@@ -200,7 +198,7 @@ mbfl_filt_conv_wchar_uhc(int c, mbfl_convert_filter *filter)
200
198
}
201
199
}
202
200
if (s >= 0 ) {
203
- if (s < 0x80 ) { /* latin */
201
+ if (s < 0x80 ) { /* latin */
204
202
CK ((* filter -> output_function )(s , filter -> data ));
205
203
} else {
206
204
CK ((* filter -> output_function )((s >> 8 ) & 0xff , filter -> data ));
0 commit comments