First, you do know hat #0 (null character) signifies the end of a null terminated string (hence the name null terminated), so the method showed that worked for you will never work with any delphi function that converts pchar to string
Once the functions encounter the #0, the string is terminated, effectively the example you gave here #0'tt' is a blank string

Now converting PChar to a string is quite simple
s := string(pchar)

It seems you are trying to do something that is not conventional so you will have to stick to your own methods. No delphi function is going to help you in this case

The delphi way to do this would be
function ConcatThis(const s : String; pc : PChar): String;
begin
Result := s + String(pc);
end;
This would give you back the result ' asdf', since #0 signifies end of your string

If you want it your way, stick to using character buffers of variable length only. But again, once you convert them to strings, your string will be truncated at the first position of #0. And don't even think of using this in windows APIs, you will always get incorrect values back

I do know what that #0 character is.
I do know that what I'm doing is not normal.

Now, your statement that "your string will be truncated at the first position of #0" it's a bit of... mmh.... not totally correct.
You're probably talking that when using that string in a UI, it will look truncated. But I never say I was trying to show this value to a user.

The fact is a string is able to hold null values in any position.
It's not normal to do that. But in my situation, I'm working with other's people components, and I can't change the way they wrote it.

SetString copies contents of a given buffer to a string variable, it is not converting the buffer to a string.
This functions exactly the way you did your solution by moving a block of characters from one memory location to another, It is not converting the PChar to a string

Featured Post

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work. Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…

If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …

To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…