home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1998 January (DVD)
/
VPR980100.ISO
/
OLS
/
WIN32
/
MM95370
/
MM95370.LZH
/
ZENHAN.MAC
< prev
next >
Wrap
Text File
|
1996-11-22
|
2KB
|
99 lines
// [全角/半角変換マクロ]
// zenhan.mac
//
// 現カーソル位置から連続する全角文字列を半角文字列へ、
// 連続する半角文字列を全角文字列へ変換します。
// ・変換例
// 1234567890 <--> 1234567890
// アイウエオガギグゲゴ <--> アイウエオガギグゲゴ
// サシスセソパピプペポ <--> サシスセソパピプペポ
//
int aCode, oCode;
char *p;
main()
{
int saveIns;
p = " !”#$%&’()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[¥]^_‘abcdefghijklmnopqrstuvwxyz{|}~ 。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゛゜ガギグゲゴザジズゼゾダヂヅデドパピプペポバビブベボ";
saveIns = Ins;
InsMode(0);
aCode = Tcode;
if(Kcode)
zentohan();
else
hantozen();
InsMode(saveIns);
}
// 半角 --> 全角/変換
hantozen()
{
int c, c1, c2;
DispOff();
while(Tcode == aCode)
{
c = Code - 0x20;
if(c < 0)
break;
if(c >= 0x80)
c = c - 0x20;
if(Code == '゙' && oCode >= 0x76 && oCode <= 0x8e)
{
c = oCode + (0xa0 - 0x76);
Bs();
}
else if(Code == '゚' && oCode >= 0x8a && oCode <= 0x8e)
{
c = oCode + (0xaf - 0x8a);
Bs();
}
oCode = c;
PutChr((p[c*2] << 8) + (p[c*2+1] & 0xff));
}
DispOn();
}
// 全角 --> 半角/変換
zentohan()
{
int c, d, d1, d2;
DispOff();
while(Tcode == aCode)
{
StrChr(Code, p);
c = Result / 2;
if(Result < 0)
break;
d = 0;
if(c >= 0xa0)
{
if(c < 0xaf || c > 0xb3)
{
c = c - (0xa0 - 0x76);
d = '゙';
}
else
{
c = c - (0xaf - 0x8a);
d = '゚';
}
}
c = c + 0x20;
if(c >= 0x80)
c = c + 0x20;
PutChr(c);
if(d)
{
InsMode(1);
PutChr(d);
InsMode(0);
}
}
DispOn();
}