> On Oct 6, 2020, at 2:12 AM, Michael Van Canneyt via fpc-pascal 
> <fpc-pascal@lists.freepascal.org> wrote:
> 
> // Read raw content as bytes
> 
> Function GetFileContents(Const aFileName : RawByteString) : TBytes;
> Function GetFileContents(Const aFileName : UnicodeString) : TBytes;
> Function GetFileContents(Const aHandle : THandle) : TBytes;
> 
> // Read content as string
> 
> // Assume TEncoding.SystemEncoding
> Function GetFileAsString(Const aFileName : RawByteString) : RawByteString;
> // Specify encoding
> Function GetFileAsString(Const aFileName : RawByteString; aEncoding : 
> TEncoding) : RawByteString;
> // Assume TEncoding.Unicode contents
> Function GetFileAsString(Const aFileName : UnicodeString) : UnicodeString;
> // Specify encoding, return Unicode string.
> Function GetFileAsString(Const aFileName : UnicodeString; aEncoding : 
> TEncoding) : UnicodeString;

Michael,  Is it possible to extend this same set of functions to writing? 
Naturally I need to write back to the file now and the same problem presents 
itself. I have to search through other code bases to find a function or Google 
and find https://wiki.freepascal.org/File_Handling_In_Pascal which offers a 
whole host of options. SaveStringToFile from the wiki link wraps TFileStream 
but having a single low-level function would be best. 

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to