哪位大哥,帮我把C++的一个涵数程序转成DELPHI的?(50)

  • 主题发起人 yeyunfeng
  • 开始时间
Y

yeyunfeng

Unregistered / Unconfirmed
GUEST, unregistred user!
CString EncodeCode128BByFont(CString text){ char *encodedtext = new char[text.GetLength()+4]; char *p_encodedtext = encodedtext; long checksum = 0; int k = 0; *p_encodedtext++ = 0x7C; checksum += 104; for(k=0;k<text.GetLength();k++) { *p_encodedtext++ = text.GetAt(k); checksum += (text.GetAt(k)-32)*(k+1); } checksum%=103; checksum+=32; *p_encodedtext++ = checksum; *p_encodedtext++ = 0x7E; *p_encodedtext = 0; CString ret = encodedtext; return ret;}
 
//文本编码,将一段文本前加上'|',文本尾加上检验和以及'~'#0定界字符function EncodeText(const InText:string):string;var I:Integer; CheckSum:Integer;begin //设置 返回字符串长度 SetLength(Result,Length(InText)+4); //字符 0x7c Result[1]:='|'; CheckSum:=104; for I:=1 to Length(InText) do begin Result[I+1]:=InText; Inc(CheckSum,(Byte(InText)-32)*I); end; CheckSum:=CheckSum mod 103 +32; //取校验合低字节 Result[I+1]:=Char(CheckSum); //定界字符 0X7C 及 终止符#0 PSmallInt(@Result[I+2])^:=$007E;end;
 
这段代码有何用处?
 

Similar threads

I
回复
0
查看
583
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
730
import
I
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
803
import
I
顶部