int han2zen(unsigned int *zenkaku, unsigned char *str)
{
static unsigned int z[64] = {
0x2121, 0x2123, 0x2156, 0x2157, 0x2122, 0x2126, 0x2572, 0x2521,
0x2523, 0x2525, 0x2527, 0x2529, 0x2563, 0x2565, 0x2567, 0x2543,
0x213c, 0x2522, 0x2524, 0x2526, 0x2528, 0x252a, 0x252b, 0x252d,
0x252f, 0x2531, 0x2533, 0x2535, 0x2537, 0x2539, 0x253b, 0x253d,
0x253f, 0x2541, 0x2544, 0x2546, 0x2548, 0x254a, 0x254b, 0x254c,
0x254d, 0x254e, 0x254f, 0x2552, 0x2555, 0x2558, 0x255b, 0x255e,
0x255f, 0x2560, 0x2561, 0x2562, 0x2564, 0x2566, 0x2568, 0x2569,
0x256a, 0x256b, 0x256c, 0x256d, 0x256f, 0x2573, 0x212b, 0x212c};
typedef struct {
unsigned char han;
unsigned int zen;
} TBL;
static TBL daku[] = {
{0xb3, 0x2574},{0xb6, 0x252c},{0xb7, 0x252e},{0xb8, 0x2530},
{0xb9, 0x2532},{0xba, 0x2534},{0xbb, 0x2536},{0xbc, 0x2538},
{0xbd, 0x253a},{0xbe, 0x253c},{0xbf, 0x253e},{0xc0, 0x2540},
{0xc1, 0x2542},{0xc2, 0x2545},{0xc3, 0x2547},{0xc4, 0x2549},
{0xca, 0x2550},{0xcb, 0x2553},{0xcc, 0x2556},{0xcd, 0x2559},
{0xce, 0x255c},{0,0}};
static TBL handaku[] = {
{0xca, 0x2551},{0xcb, 0x2554},{0xcc, 0x2557},{0xcd, 0x255a},
{0xce, 0x255d},{0,0}};
int i;
if (*str < 0xa0 || *str > 0xdf) return 0;
if (*(str+1) == 0xde) { /* ŹÀ½ºÎ */
for (i = 0; daku[i]. zen ! = 0; i++)
if (*str == daku[i]. han) {
*zenkaku = daku[i]. zen;
return 2;
}
} else if (*(str+1) == 0xdf) { /* ¹ÝŹÀ½ºÎ */
for (i = 0; handaku[i]. zen ! = 0; i++)
if (*str == handaku[i]. han) {
*zenkaku = handaku[i]. zen;
return 2;
}
}
*zenkaku = z[*str - 0xa0];
return 1;
}