cb有没有直接转换全角字符为半角字符的函数?要自己写吗?
cb有没有直接转换全角字符为半角字符的函数?要自己写吗?
[解决办法]
void __fastcall TForm1::btn_2Click(TObject *Sender) // 全角字符转化为半角字符
{
int ilength = edt_Big-> Text.Length();
if(ilength <1) return;
AnsiString str = " ";
char * cTemp = new char[ilength+1];
StrPCopy(cTemp,edt_Big-> Text);
BYTE c1,c2;
for(int i=0; i <ilength; i++){
c1 = cTemp[i];
c2 = cTemp[i+1];
if(c1 == 163){ // 判断是否为全角字符
str = str + String((char)(c2-128));
i++;
continue;
}else if(c1 > 163){ // 判断是否为文字
str = str + String((char)c1);
str = str + String((char)c2);
i++;
continue;
}else if(c1 == 161 && c2==161){ // 全角字符是一个特例,另加处理
str = str+ " ";
i++;
continue;
}
str = str + String((char)c1);
}
edt_Small-> Text = str;
delete cTemp;
}
[解决办法]
LCMapString可以进行半全角及简繁转换,具体使用方法参看
http://msdn2.microsoft.com/en-us/library/ms776290.aspx
[解决办法]
我也晕一下这是API函数BCB也可以照样用……
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winnls.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT