求高手 Delphi 代码转 c#
//这是一个函数
function StrTOBcd(Str: string): string;
var
aa, n,i, Bytes: Byte;
Odd: boolean;
hex1,Hex: string;
begin
str := trim(str); //去空格和回车等特殊字符
str := stringreplace(str, ' ', '', [rfReplaceAll]);
Result := '';
Odd := Length(Str) mod 2 = 1;
Bytes := (Length(Str) + 1) div 2;
if Odd then Str := Str + '0';
for i := 0 to Bytes - 1 do
begin
Hex := Copy(Str, i * 2 + 1, 2);
//ShowMessage(chr(01));
Result := Result + chr(HexToInt(Hex));
end;
end;
//另一个
function BcdTOstr(ss: string): string;
var
i: integer;
s, s2: string;
begin
for i := 1 to length(ss) do
begin
s2 := ss[i];
s := s + BCD2Str(pchar(s2), 0, 2);
end;
result := s;
end;
function BCD2Str(P: PChar; Pos, Len: integer): string;
var
i: integer;
strResult: string;
cRead: Byte;
cReadH, cReadL: Byte;
bOdd: boolean;
begin
strResult := '';
if (Len mod 2) = 1 then
begin
Len := (Len + 1) div 2;
bOdd := true;
end else begin
Len := Len div 2;
bOdd := false;
end;
for i := 0 to Len - 1 do
begin
cRead := Ord(P[pos + i]);
cReadH := (cRead and $F0) shr 4;
strResult := strResult + IntToHex(cReadH, 1);
if (i = Len - 1) and bOdd then continue;
cReadL := cRead and $0F;
strResult := strResult + IntToHex(cReadL, 1);
end;
BCD2Str := strResult;
end;
...全文
相关推荐
Delphi 转 C#
标题 "Delphi 转 C#" 指的是将用 Delphi 编程语言编写的代码转换成 C# 语言的过程。
delphi转c#工具
标题中的“Delphi转C#工具”指的是一个专门用于将Delphi编写的代码转换为C#语言的软件。
delphi转C#工具
本文将围绕“Delphi转C#工具”这一主题,探讨如何借助专门的转换工具,平滑过渡到C#开发环境。
DELPHI转c#范例
【标题】"DELPHI转c#范例"所涉及的知识点主要涵盖了两个部分:Delphi编程语言与C#编程语言的对比与转换。
delphi转c#破解版
Delphi程序转换成C#工具,以破解,突破转换代码行数限制。可以更快捷的将Delphi代码转换成c#代码,节省代码翻译时间。


