Delphi中实现全角转半角
Delphi中实现全角转半角
function SbctoDbc(s:string):string;
var
nlength,i:integer;
str,ctmp,c1,c2:string;
{
在windows中,中文和全角字符都占两个字节,
并且使用了ascii chart 2
(codes 128 - 255
)。
全角字符的第一个字节总是被置为163,
而第二个字节则是相同半角字符码加上128(不包括空格)。
如半角a为65,则全角a则是163(第一个字节)、
193 (第二个字节, 128 + 65 )。
而对于中文来讲,它的第一个字节被置为大于163,(
如 ' 阿 ' 为:
176 162 ),我们可以在检测到中文时不进行转换。
}
begin
nlength: =
length(s);
if (nlength = 0 ) then
exit;
str: = '' ;
setlength(ctmp,nlength + 1 );
ctmp: = s;
i: = 1 ;
while (i # 163 ) then //
如果是汉字
begin
str:
= str + c1;
str: = str +
c2;
inc(i, 2
);
continue ;
end;
if (c1 = # 161 ) and (c2 = # 161 )
then // 如果是全角空格
begin
str: = str + ' '
;
inc(i, 2
);
continue ;
end;
str: = str + c1;
inc(i);
end;
result: = str;
end; ---
本文章使用“国华软件”出品的博客内容离线管理软件MultiBlogWriter撰写并发布
相关文档:
今天开始研究FastReport。
以下是动态创建FASTREPORT的DEMO
var
Page: TfrxReportPage;
Band: TfrxBand;
DataBand: TfrxMasterData;
Memo: TfrxMemoView;
begin
{ clear a report }
frxReport1.Clear;
{ add a dataset to the list of ones accessible for a report }
frxReport1.DataSets.Add(frxDB ......
当A D O开始处理数据后,应用程序必须等到A D O处理完毕之后才可以继续执行。但
是除了同步执行方式之外, A D O也提供了异步执行的方式,允许当A D O处理时,
应用程序仍然能够先继续执行。而当A D O处理数据完毕之后, A D O会以事件的方
式通知应用程序,此时应用程序可以再根据A D O执行的 ......
ADO 使用 ORACLE provider FOR OLE DB 驱动时
调用存储过程需要返回游标时,在连接字符串中增加
PLSQLRSet=1 参数。
存储过程中的游标不需要付初始值
如:
sp1: TADOStoredProc;
sp1.Close;
sp1.ProcedureName := 'pkg_ScanList_By_JobNo.sp_GetScanList';& ......
//Delphi部分
//回调函数定义
type TOnMyCallBack = procedure(data:pchar; id:Integer);stdcall;
//DLL中的导出函数声明
procedure StartCall(param: TOnMyCallBack(data:pchar; id:Integer);stdcall;
begin
...
...
end;
&n ......