- 배열을 문자열로 변환
- procedure SetString(var S: String; Buffer: PChar; Length: Integer);
- Sets the contents and length of the given string.
In Delphi code, SetString sets the contents and length of the given string variable to the block of characters given by the Buffer and Length parameters.
For a short string variable, SetString sets the length indicator character (the character at S[0]) to the value given by Length and then, if the Buffer parameter is not nil, copies Length characters from Buffer into the string, starting at S[1]. For a short string variable, the Length parameter must be a value from 0 through 255.
For a long string variable, SetString sets S to reference a newly allocated string of the given length. If the Buffer parameter is not nil, SetString then copies Length characters from Buffer into the string; otherwise, the content of the new string is left uninitialized. If there is not enough memory available to create the string, an EOutOfMemory exception is raised. Following a call to SetString, S is guaranteed to reference a unique string (a string with a reference count of one).
- Sets the contents and length of the given string.
- procedure SetString(var S: String; Buffer: PChar; Length: Integer);
- 문자열을 배열로 변환
- function StrPCopy(Dest: PAnsiChar; const Source: AnsiString): PAnsiChar;
- function StrPCopy(Dest: PWideChar; const Source: UnicodeString): PWideChar;
- Copies an AnsiString (long string) to a null-terminated string.
StrPCopy copies Source into a null-terminated string Dest. It returns a pointer to Dest.
StrPCopy does not perform any length check.
The destination buffer must have room for at least Length(Source)+1 characters.
- Copies an AnsiString (long string) to a null-terminated string.
- Sample
- var
arr: array [0..5] of Byte;
strAnsi, str2: AnsiString;
begin
arr[0] := $31;
arr[1] := $32;
arr[2] := $33;
arr[3] := $34;
arr[4] := $35;
SetString(strAnsi, PAnsiChar(@arr[0]), 5);
ShowMessage(string(strAnsi));
FillChar(arr, SizeOf(arr), 0);
StrPCopy(@arr[0], strAnsi);
str2 := AnsiChar(arr[0]) + AnsiChar(arr[1]) + AnsiChar(arr[2]) + AnsiChar(arr[3]) + AnsiChar(arr[4]);
ShowMessage(string(str2));
- var
반응형
'Delphi' 카테고리의 다른 글
| [Delphi] 파일 속성변경 (0) | 2023.05.15 |
|---|---|
| [Delphi] DB Grid 에서 현재 선택된 Row Number (0) | 2022.12.15 |
| [Delphi] 마우스 커서 변경 (0) | 2022.11.09 |
| [Delphi] Save string into Text File (0) | 2022.11.03 |
| [Delphi] 특정 서비스 프로그램 실행여부 확인 (0) | 2022.10.13 |