在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Delphi StrPas和StrPCopy - String转Char / Char 转 String 函数原型: StrPas {$IFNDEF NEXTGEN}
function StrPas(const Str: PAnsiChar): AnsiString;
begin
Result := Str;
end;
{$ENDIF !NEXTGEN}
function StrPas(const Str: PWideChar): UnicodeString;
begin
Result := Str;
end;
StrPCopy {$IFNDEF NEXTGEN}
function StrPCopy(Dest: PAnsiChar; const Source: AnsiString): PAnsiChar;
begin
Result := StrLCopy(Dest, PAnsiChar(Source), Length(Source));
end;
{$ENDIF !NEXTGEN}
function StrPCopy(Dest: PWideChar; const Source: UnicodeString): PWideChar;
begin
Result := StrLCopy(Dest, PWideChar(Source), Length(Source));
end;
function StrLCopy(Dest: PWideChar; const Source: PWideChar; MaxLen: Cardinal): PWideChar;
var
Len: Cardinal;
begin
Result := Dest;
Len := StrLen(Source);
if Len > MaxLen then
Len := MaxLen;
Move(Source^, Dest^, Len * SizeOf(WideChar));
Dest[Len] := #0;
end;
Delphi 使用示例: var
Msgs:array[0..255] of Char;
Str:string;
begin
StrPCopy(Msgs,Memo1.Text); // j将Memo1.text的值复制到Msgs
Str:=StrPas(Msgs); //将Msgs的值输出为字符串类型
end
创建时间:2020.06.04 更新时间:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论