like as
ZTable1.Locate('test_field','Л',[loCaseInsensitive, loPartialKey]);
not found 'л'
patch also fixes crashes Postgres with UTF8 in Lazarus
Code: Select all
Index: src/component/ZDatasetUtils.pas
===================================================================
--- src/component/ZDatasetUtils.pas (revision 903)
+++ src/component/ZDatasetUtils.pas (working copy)
@@ -909,8 +909,13 @@
DecodedKeyValues[I], vtString);
if CaseInsensitive then
begin
+ {$IFDEF FPC}
DecodedKeyValues[I].VString :=
+ WideUpperCase(UTF8Decode (DecodedKeyValues[I].VString));
+ {$ELSE}
+ DecodedKeyValues[I].VString :=
AnsiUpperCase(DecodedKeyValues[I].VString);
+ {$ENDIF}
end;
end;
end
@@ -955,8 +960,13 @@
begin
DecodedKeyValues[I] := SoftVarManager.Convert(
DecodedKeyValues[I], vtString);
+ {$IFDEF FPC}
DecodedKeyValues[I].VString :=
+ WideUpperCase(UTF8Decode (DecodedKeyValues[I].VString));
+ {$ELSE}
+ DecodedKeyValues[I].VString :=
AnsiUpperCase(DecodedKeyValues[I].VString);
+ {$ENDIF}
end
else
begin
@@ -1015,7 +1025,11 @@
end;
if CaseInsensitive then
- Value2 := AnsiUpperCase(Value2);
+ {$IFDEF FPC}
+ Value2 := AnsiUpperCase(Utf8ToAnsi(Value2));
+ {$ELSE}
+ Value2 := AnsiUpperCase(Value2);
+ {$ENDIF}
Result := AnsiStrLComp(PAnsiChar(Value2), PAnsiChar(Value1), Length(Value1)) = 0;
end
else
@@ -1064,8 +1078,13 @@
else
if CaseInsensitive then
begin
+ {$IFDEF FPC}
Result := KeyValues[I].VString =
+ AnsiUpperCase (Utf8ToAnsi(ResultSet.GetString(ColumnIndex)));
+ {$ELSE}
+ Result := KeyValues[I].VString =
AnsiUpperCase(ResultSet.GetString(ColumnIndex));
+ {$ENDIF}
end
else
begin
Index: src/dbc/ZDbcPostgreSqlResultSet.pas
===================================================================
--- src/dbc/ZDbcPostgreSqlResultSet.pas (revision 903)
+++ src/dbc/ZDbcPostgreSqlResultSet.pas (working copy)
@@ -197,7 +197,7 @@
if Connection.GetCharactersetCode = csUTF8 then
case SQLType of
- stString: SQLType := stUnicodeString;
+ stString: SQLType := {$IFDEF FPC} stString; {$ELSE} stUnicodeString; {$ENDIF}
stAsciiStream: SQLType := stUnicodeStream;
end;
Index: src/dbc/ZDbcPostgreSqlUtils.pas
===================================================================
--- src/dbc/ZDbcPostgreSqlUtils.pas (revision 903)
+++ src/dbc/ZDbcPostgreSqlUtils.pas (working copy)
@@ -285,7 +285,7 @@
if Connection.GetCharactersetCode = csUTF8 then
case Result of
- stString: Result := stUnicodeString;
+ stString: Result := {$IFDEF FPC} stString; {$ELSE} stUnicodeString; {$ENDIF}
stAsciiStream: Result := stUnicodeStream;
end;
end;