[fpc-devel] TStringList.LoadFromFile and SavetoFile - file encoding support
sergei_gorelkin at mail.ru
Tue Feb 3 12:33:10 CET 2009
Graeme Geldenhuys wrote:
> The point is that you will probably have a File Open dialog that gives
> the filename to TMemo.LoadFromFile. The the file dialog could collect
> the filename and optional encoding to pass on to LoadFromFile.
> Even if TStringList has the optional encoding parameter, prior source
> code should still work as-is without the encoding parameter. No code
> would be broken.
> I agree with Marco that auto detecting encodings is probably not a
> good idea in the RTL, but at least enable the option of a encoding
> parameter in TStringList, which could help things along. As in the
> case of the bug report.
There is no need for TStrings.LoadFromFile method at all.
The container is one matter, and its serialization is a separate one.
Just introduce a decoding stream and you can write e.g:
This approach isn't limited to decoding, you can do decrypting,
In reality, of course, you have to finalize all the stuff - that means
typing more than one line. C++ language that automatically finalizes
on-stack objects is more friendly in this respect.
More information about the fpc-devel