TFieldDef does not support Multibyte character sets
Original Reporter info from Mantis: TWhyman
-
Reporter name: Tony Whyman
Original Reporter info from Mantis: TWhyman
- Reporter name: Tony Whyman
Description:
TField.DisplayWidth provides the actual character width for displaying a field (e.g. a string) as distinct from TField.Size which is the storage size for the string. With multibyte character sets, Display Width should typically be the Field Size divided by the max. number of bytes per character.
However, TFieldDef only supports the field size and not the display width or bytes per character. There is thus no direct means for a database driver to communicate the use of multibyte character sets to a TField e.g. when it is created by TFieldDef.CreateField.
Steps to reproduce:
The attached patch adds a new property to TFieldDef and TStringField This is CharSetWidth. This is the number of bytes per character and defaults to 1.When TFieldDef.CreateField creates a TStringField, it passes the property value on to the TStringField.
For TStringField, the DefaultWidth is the calculated as FSize div FCharSetWidth unless explicitly set by the user.
Additional information:
This problem can be worked around. For example, in IBX i have experimented with encoding both field size and char width in the TFieldDef.Size then decoding it in TIBStringField. However, a clean way to do this is very desirable.
Mantis conversion info:
- Mantis ID: 27766
- OS: Linux Mint
- OS Build: 17
- Platform: AMD64
- Version: 2.6.4
- Fixed in version: 3.3.1
- Monitored by: » and (Andrew G. Khodotov)
- Target version: 3.2.0