[fpc-devel] What's the state of "string"?

Hans-Peter Diettrich DrDiettrich1 at aol.com
Wed Mar 21 03:32:23 CET 2012


I wonder about much code in the RTL/FCL, that depends on String type 
arguments, like:

   Procedure TStream.WriteAnsiString (const S : String);
   Var L : Longint;
   begin
     L:=Length(S);
     WriteBuffer (L,SizeOf(L));
     WriteBuffer (Pointer(S)^,L);
   end;

This method will work only as long as String=AnsiString, because Length 
*bytes* are written, not *chars* of a possibly different byte count.


Is the use of generic types, like String, really okay in the library 
code, when the concrete type matters?

The documentation on strings (3.2 Character types) is not really 
helpful, most entries look like they deserve an update reflecting the 
role of UnicodeString and the generic String type, and implicit string 
conversions. In detail I miss instructions on how to determine or 
specify the String type, with different FPC versions.

DoDi




More information about the fpc-devel mailing list