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:

Strings.LoadFromStream(TDecodingStream.Create(TFileStream.Create('myfile'), 'cp866', 'utf-8'));

This approach isn't limited to decoding, you can do decrypting, compressing, etc. 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.

Regards,
Sergei
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to