TStringField may return wrong size for TStringField.DataSize
Original Reporter info from Mantis: marsupilami79
-
Reporter name: Jan Baumgarten
Original Reporter info from Mantis: marsupilami79
- Reporter name: Jan Baumgarten
Description:
TStringField assumes that DataSize is always Size + 1 which is not always true for UTF-8 encoded Strings.
The FCL documentation states:
Size [...] is the declared maximum size of the string (in characters) [...].
So a TStringField where TStringField.Size is 5 should be able to store the String 'äöüßó', which has a Size of 10 bytes if it is encoded in UTF-8.
Unfortunately this is not possible with the current implementation of TStringField because in this case TStringField returns 6 for TStringField.GetDataSize which is too small for storing 10 Bytes of character information.
This leads to an ambiguity when using the TStringField.Size value for further processing because application programmers might check it to see wether a string fits into a field.
Mantis conversion info:
- Mantis ID: 25801
- OS: Windows
- OS Build: Windows 7
- Version: 2.6.2
- Fixed in version: 3.1.1
- Monitored by: » marsupilami79 (Jan Baumgarten), » evdb (Erwin van den Bosch), » luizamerico (Luiz Americo), » and (Andrew G. Khodotov), » EgonHugeist (EgonHugeist/ZeosDevTeam)
- Target version: 3.2.0