[Lazarus] TDBEdit, TStringField Size, DataSize, DisplayWidth and MaxLength

Martin Schreiber mse00000 at gmail.com
Tue Oct 11 16:14:46 CEST 2016


On Tuesday 11 October 2016 15:48:15 Tony Whyman via Lazarus wrote:
> Please look at changes in TRUNK.
>
> > May be that not all is perfect, but you will see there direction ...
> >
> > -Laco.
>
> Which FPC version is this likely to be released in?
>
> On a quick review of the code, all seems good. Just one point:
> GetDataSize seems to acknowledge CP_UTF8 as the only multibyte character
> set. The Firebird character set GB18030 (Chinese characters) is
> multi-byte (see wikipedia) and has code page 54936. I believe PostgreSQL
> also supports it.

MSEgui uses below code in order to guess the Firebird character size:
"
       SQL_TEXT,SQL_VARYING: begin
        size:= metadata.getlength(fapi.status,i1);
        datatype:= ftstring;
        i2:= metadata.getcharset(fapi.status,i1);
        if _type = SQL_TEXT then begin
         fetchfunc:= @fetchtext;
         if i2 = cs_binary then begin
          if size = 16 then begin
           datatype:= ftguid;
           fetchfunc:= @fetchguid;
           size:= 0;
          end
          else begin
           datatype:= ftbytes;
          end;
         end;
        end
        else begin
         if i2 = cs_binary then begin
          datatype:= ftvarbytes;
          fetchfunc:= @fetchvarbytes;
         end
         else begin
          fetchfunc:= @fetchvarchar;
         end;
        end;
        case i2 of
         5,6,8,44,56,57,64: begin
          i3:= 2;
         end;
         3: begin
          i3:= 3;
         end;
         4,59: begin
          i3:= 4;
         end;
         else begin
          i3:= 1;
         end;
        end;
        size:= size div i3;
       end;
"
From 
https://gitlab.com/mseide-msegui/mseide-msegui/blob/master/lib/common/db/msefbconnection.pas

Martin


More information about the Lazarus mailing list