shwq.net
当前位置:首页 >> DElphi BytE数组怎么转换成String >>

DElphi BytE数组怎么转换成String

用char() var ss:Byte; begin ss:=$31; showmessage(char(ss)); 如果你是想byte:=9 的时候 转为字符串9 那就直接用 inttostr()

以下为示例代码: procedure TForm1.Button1Click(Sender: TObject);var s:string; ab:array of byte; i:integer;begin s:='this is a test'; SetLength(ab,Length(s)); for i:=1 to length(s) do ab[i]:=byte(s[i]);end;

var arrbyte: array[0..2] of Byte; str1: string; i: Integer; begin for i := 0 to Length(arrbyte)-1 do str := str + IntToStr(arrbyte[i]);//byte[] to string; for i := 0 to Length(str)-1 do arrbyte[i] := Byte(str[i]);//string to by...

const a: array[0..5] of Byte = (4,5,1,8,0,7); var i: Integer; str: String; begin str:= ''; for i:= 0 to High(a) do str:= str + IntToStr(a[i]); ShowMessage(str); end;

{转换 TBytes 到 Integer}procedure TForm1.Button1Click(Sender: TObject);var bs: TBytes; {TBytes 就是 Byte 的动态数组} i: Integer;begin {它应该和 Integer 一样大小才适合转换} SetLength(bs, 4); bs[0] := $10; bs[1] := $27; bs[2] := ...

如果是 带中文的String 转byte function UniCode2GB(S: string): string; var I: Integer; begin I := Length(S); while I >= 4 do begin try Result := WideChar(StrToInt('$' + S[I - 3] + S[I - 2] + S[I - 1] + S[I])) + Result; except end...

你的Delphi是不是Delphi2009以上的版本,如果是的话默认的String是WideString.你所说的7个字节的String事实上是AnsiString。方法一事实上可以简化为: const str: AnsiString = '中文abc';var buf: array of Byte; len: Integer;begin //获取ans...

用char() var ss:Byte; begin ss:=$31; showmessage(char(ss)); 如果你是想byte:=9 的时候 转为字符串9 那就直接用 inttostr()

var Buf:TBytes; w:Word;begin w:=2; Buf:=RawToBytes(w);end;var Buf:Array[0..1] of Byte; w:Word;begin w:=2; Move(w,Buf[0],2);end;

网站首页 | 网站地图
All rights reserved Powered by www.shwq.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com