![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 5 of 5 total |
![]() |
Wed, Apr 15 2009 1:11 AM | Permanent Link |
Jaakko Salmenius | Hi
TDataset.Locate did not work correctly when working with Delphi 2009 and fields that contain UTF-8 or Ansi strings having different code page as the system code page. The reason was that the code in dbisamtb.pas assings KeyValues to the Value property of a field. In this case the field is a TStringField and Delphi 2009 VCL is converting the Ansi string (UTF-8 or code page encodede) to UnicodeString. This causes the locate logic to compare the the values in the database to UnicodeString when it should compare to AnsiStrings. DBISAM does not contain WideString fields so all strings in the database are Ansi, right? To make Locate working with strings do not just assing KeyValue to the Value property of TField but check if the field is a string field and if the varian contains AnsiString set the AsAnsiString property instead of Value property. The following code contains fixes marked with //JS Line:9716 begin if (TempField is TLargeIntField) then TLargeIntField(TempField).AsLargeInt:=KeyValues //JS else if (TempField is TStringField) and (FindVarData(KeyValues)^.VType = varString) then TStringField(TempField).AsAnsiString:=KeyValues //JS else TempField.Value:=KeyValues; end; Best regards, Jaakko |
Wed, Apr 15 2009 1:15 AM | Permanent Link |
Jaakko Salmenius | Two more things:
- This code should be used only with Delphi 2009 and later - The similar code should be used few lines earlier where variant is an array variant. |
Tue, Apr 21 2009 1:25 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Jaakko,
<< TDataset.Locate did not work correctly when working with Delphi 2009 and fields that contain UTF-8 or Ansi strings having different code page as the system code page. The reason was that the code in dbisamtb.pas assings KeyValues to the Value property of a field. In this case the field is a TStringField and Delphi 2009 VCL is converting the Ansi string (UTF-8 or code page encodede) to UnicodeString. This causes the locate logic to compare the the values in the database to UnicodeString when it should compare to AnsiStrings. >> I will check this out and make the necessary adjustments. << DBISAM does not contain WideString fields so all strings in the database are Ansi, right? >> Yes. Thanks, -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Jun 2 2009 3:04 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Jaako,
<< To make Locate working with strings do not just assing KeyValue to the Value property of TField but check if the field is a string field and if the varian contains AnsiString set the AsAnsiString property instead of Value property. >> Do you have an example project that demonstrates where the issue is ? I'm looking at the D2009 source, and effectively all TStringField's are already treated as AnsiString values. For example, the SetAsString method for the TStringField is this: procedure TStringField.SetAsString(const Value: string); begin SetAsAnsiString(AnsiString(Value)); end; IOW, it casts it to an AnsiString and assigns the value. The same is true for the variants: procedure TStringField.SetVarValue(const Value: Variant); begin SetAsString(Value); end; which just calls the SetAsString method. I don't see how your code changes the behavior of the string conversions at all. -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Jun 2 2009 5:19 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Jaako,
Never mind - I wasn't thinking straight. I now see the problem with the conversion to and from the UnicodeString. It causes the string to "lose" its code page in the process if it is different from the system code page. However, just keep in mind that this type of issue can be found all over the VCL, so it probably isn't the only place where this type of issue exists. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Wednesday, August 14, 2024 at 03:12 PM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |