I have a structure like below that needs to be saved and loaded from disk.
RSecStructure= packed record Name : string[255]; {NEED UNICODE SUPPORT HERE} ScreenName : string[255]; OrigFileName : string[255]; Prim : string[255]; ParentVersion : integer; sTag1 : string[255]; sTag2 : string[255]; sTag3 : string[255]; sTag4 : string[255]; DateAdd : TDateTime; DateModify : TDateTime; end;
Until now I have used something like this to save the structure:
function var F: FILE; Hdr: RSecStructure; begin ... BlockWrite (F, Hdr, SizeOf(Hdr)); ... end
The above code worked under Delphi 7. Under D2009 I got a lot of warning messages when I make assignments between short and Unicode strings. Until now I managed to write Delphi code without having ANY compiler warnings or hints and I want to stay like that. So I need an elegant was to save strings (Unicode will be great but not critical) to disk without getting warnings.
Alternatively, you can declare storable short unicode string record and implement implicit ‘to string’ and ‘from string’ conversions.
[The code above is released to public domain and carries no license obligations.]