[fpc-devel] new string - question on usage

Marco van de Voort marcov at stack.nl
Tue Oct 11 11:00:18 CEST 2011


In our previous episode, Hans-Peter Diettrich said:
> > And what happens if an app did read data from some external source 
> > (serial port) and then wants to declare what encoding it is?
> 
> That's not different from the current situation. Network communication 
> must agree about the encoding to use, and the user is responsible for 
> the correct encoding when local files are read or written. When files 
> are stored in UTF-8 (or UTF-16), a BOM will leave no room for wrong 
> guessing.

Note that many places that are runtime typed (like tstringlist.loadfromfile)
get a encoding parameter, so that the loading code can convert the encoding
of the file (in encoding parameter) to whatever stringtype tstringlist uses
(typically utf8 or utf16 or "default")

In short, see it as if text now has a mandatory encoding attached. If the
runtime doesn't know the type, then it is not text, but binary, and you
should treat it as such.



More information about the fpc-devel mailing list