Field size not correct for UTF8
Original Reporter info from Mantis: tema
-
Reporter name: Artem Proskurnev
Original Reporter info from Mantis: tema
- Reporter name: Artem Proskurnev
Description:
When the database returns UTF8 string of Russian letters, they calculated wrong and the letters are cut off. For example, the database field is specified the size of a single symbol and there is the Russian letter "М" or "Ж". Lazarus creates a field size of 1 and half the letter is cut off, because it actually is two characters. Temporarily I did to fix this issue (Very bad. I known):
packages/fcl-db/src/base/fields.inc
constructor TFieldDef.Create(AOwner: TFieldDefs; const AName: string;
ADataType: TFieldType; ASize: Integer; ARequired: Boolean; AFieldNo: Longint;
ACodePage: TSystemCodePage);
begin
{$ifdef dsdebug }
Writeln('TFieldDef.Create : ',Aname,'(',AFieldNo,')');
{$endif}
Inherited Create(AOwner);
Name:=Aname;
FDatatype:=ADatatype;
FSize:=ASize;
FRequired:=ARequired;
FPrecision:=-1;
FFieldNo:=AFieldNo;
case FDataType of
ftString, ftFixedChar, ftMemo:
//===============================================
begin
FCodePage := CP_UTF8;
FSize:=ASize*2;
end;
//===============================================
ftWideString, ftFixedWideChar, ftWideMemo:
FCodePage := CP_UTF16;
else
FCodePage := 0;
end;
end;