What is the best way to handle tbytes in Delphi 2007
In Delphi 2009, you can use tencoding to convert to string.
If I am sending strings from the client to the server what is the best way to pull them out of the tbytes array returned in OnDataFromClient?
Thanks,
Snorkel
OnDataFromClient and Tbytes
Hello Snorkel
I have been working with the demo version of SB and i have found some problems working with TBytes, trying to write text to the server.
Actually I found the function : Encoding.ASCII.GetString used to convert from tbytes to string, but I want the "opposite" function (i guess it has to be one function).
The problem is, i can not found the ScCLRClasses file, i guess because the demo version.
Is there any solution?
Thanks and best regrads.
- D2007 -
I have been working with the demo version of SB and i have found some problems working with TBytes, trying to write text to the server.
Actually I found the function : Encoding.ASCII.GetString used to convert from tbytes to string, but I want the "opposite" function (i guess it has to be one function).
The problem is, i can not found the ScCLRClasses file, i guess because the demo version.
Is there any solution?
Thanks and best regrads.
- D2007 -
Thanks Dimon,
I have compiled with the function you sent me but I get the same result.
This is my code:
But when i open the file in the SFTP server I get the following;
hý'
It seems (i don't know exactly) there is something with unicode.
Thanks and best regards
I have compiled with the function you sent me but I get the same result.
This is my code:
Code: Select all
cTextoArchivo := '';
FileOffset := 0;
// This is the text I will write in the new txt file in the SFTP server (actually is ascii)
cTextoArchivo := oClaseManejoArchivos.GetArchivo(slArchivos[nCicloArchivos]);
if cTextoArchivo '' then
Begin
Buffer := Encoding.ASCII.GetBytes(cTextoArchivo);
End;
if cTextoArchivo '' then
begin
try
Handle := ScSFTPClient.OpenFile(GetRootDir + slArchivos[nCicloArchivos], [foCreate, foRead, foWrite]);
ScSFTPClient.WriteFile(Handle, 0, Buffer, Sizeof(Buffer));
finally
ScSFTPClient.CloseHandle(Handle);
end;
end;
hý'
It seems (i don't know exactly) there is something with unicode.
Thanks and best regards