TOP

Delphi中常用字符串处理函数(四)
2019-08-23 00:31:48 】 浏览:252
Tags:Delphi 常用 字符串 处理 函数

w(base, power: integer): integer;
var counter : integer; begin Result:=1; for counter:=1 to power do Result:=Result*base; end; function BinStrToInt(BinStr : string) : integer; var counter : integer; begin if length(BinStr)>16 then raise ERangeError.Create(#13+BinStr+#13+ 'is not within the valid range of a 16 bit binary.'+#13); Result:=0; for counter:=1 to length(BinStr) do if BinStr[Counter]='1' then Result:=Result+pow(2,length(BinStr)-counter); end; function DecodeSMS7Bit(PDU : string):string; var OctetStr : string; OctetBin : string; Charbin : string; PrevOctet: string; Counter : integer; Counter2 : integer; begin PrevOctet:=''; Result:=''; for Counter:=1 to length(PDU) do begin if length(PrevOctet)>=7 then { if 7 Bit overflow on previous } begin if BinStrToInt(PrevOctet)<>0 then Result:=Result+Chr(BinStrToInt(PrevOctet)) else Result:=Result+' '; PrevOctet:=''; end; if Odd(Counter) then { only take two nibbles at a time } begin OctetStr:=Copy(PDU,Counter,2); OctetBin:=HexToBin(OctetStr); Charbin:=''; for Counter2:=1 to length(PrevOctet) do Charbin:=Charbin+PrevOctet[Counter2]; for Counter2:=1 to 7-length(PrevOctet) do Charbin:=OctetBin[8-Counter2+1]+Charbin; if BinStrToInt(Charbin)<>0 then Result:=Result+Chr(BinStrToInt(CharBin)) else Result:=Result+' '; PrevOctet:=Copy(OctetBin,1,length(PrevOctet)+1); end; end; end; function ReverseStr(SourceStr : string) : string; var Counter : integer; begin Result:=''; for Counter:=1 to length(SourceStr) do Result:=SourceStr[Counter]+Result; end; end.

转发于:https://blog.csdn.net/mrwlw/article/details/78238434

请关注公众号获取更多资料


Delphi中常用字符串处理函数(四) https://www.cppentry.com/bencandy.php?fid=86&id=229775

首页 上一页 1 2 3 4 下一页 尾页 4/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Delphi DBGrid类控件定位到某一行.. 下一篇delphi中WMI的使用(网卡是否接入..