Str2Bytes

type
  TBytes = array of Byte;

function Str2Bytes(const S: string): TBytes;
var
  AnsiStr: AnsiString;
begin
  if S = '' then
  begin
    Result := nil; // 或者设置为长度为0的数组
    Exit;
  end;
  AnsiStr := AnsiString(S);
  SetLength(Result, Length(AnsiStr));
  if Length(Result) > 0 then
    Move(AnsiStr[1], Result[0], Length(AnsiStr));
end;

 

posted @ 2025-02-09 15:14  Tag  阅读(11)  评论(0)    收藏  举报