void __fastcall tform1::button1click(tobject *sender)
{
int nlength=edit1->text.length();
if (nlength==0)
return;
ansistring str="";
char *ctmp=new char[nlength+1];
strpcopy(ctmp,edit1->text);
byte c1,c2;
int i;
for (i=0;i<nlength;i++)
{
c1=ctmp[i];
c2=ctmp[i+1];
if (c1==163)//判断是否为全角字符
{
str=str+ansistring((char)(c2-128));
i++;
continue;
}
if (c1>163)//判断是否为文字
{
str=str+ansistring((char)c1);
str=str+ansistring((char)c2);
i++;
continue;
}
if ((c1==161) && (c2==161))//全角空格是个特例,另加处理
{
str=str+" ";
i++;
continue;
}
str=str+ ansistring(char(c1));
}
edit2->text=str;
delete ctmp;ctmp=null;
}
{
int nlength=edit1->text.length();
if (nlength==0)
return;
ansistring str="";
char *ctmp=new char[nlength+1];
strpcopy(ctmp,edit1->text);
byte c1,c2;
int i;
for (i=0;i<nlength;i++)
{
c1=ctmp[i];
c2=ctmp[i+1];
if (c1==163)//判断是否为全角字符
{
str=str+ansistring((char)(c2-128));
i++;
continue;
}
if (c1>163)//判断是否为文字
{
str=str+ansistring((char)c1);
str=str+ansistring((char)c2);
i++;
continue;
}
if ((c1==161) && (c2==161))//全角空格是个特例,另加处理
{
str=str+" ";
i++;
continue;
}
str=str+ ansistring(char(c1));
}
edit2->text=str;
delete ctmp;ctmp=null;
}