2828interface
2929
3030uses
31- Classes, RtlConsts, SysUtils, IniFiles;
31+ Classes, RtlConsts, SysUtils, IniFiles, Math ;
3232
3333type
3434 { TFileStreamEx class }
@@ -53,7 +53,7 @@ TFileStreamEx = class(THandleStream)
5353 property AutoSync: Boolean read FAutoSync write SetAutoSync;
5454 property Capacity: Int64 write SetCapacity;
5555 property FileName: String read FFileName;
56- end ;
56+ end ;
5757
5858 { TStringListEx }
5959
@@ -64,7 +64,7 @@ TStringListEx = class(TStringList)
6464 function IndexOfValue (const Value : String): Integer;
6565 procedure LoadFromFile (const FileName: String); override;
6666 procedure SaveToFile (const FileName: String); override;
67- end ;
67+ end ;
6868
6969 { TIniFileEx }
7070
@@ -82,7 +82,7 @@ TIniFileEx = class(TMemIniFile)
8282implementation
8383
8484uses
85- DCOSUtils, LazUTF8 ;
85+ DCOSUtils, DCConvertEncoding ;
8686
8787{ TFileStreamEx }
8888
@@ -175,7 +175,7 @@ constructor TFileStreamEx.Create(const AFileName: String; Mode: LongWord);
175175 inherited Create(AHandle);
176176 end
177177 else
178- begin
178+ begin
179179 AHandle:= mbFileOpen(AFileName, Mode);
180180 if AHandle = feInvalidHandle then
181181 raise EFOpenError.CreateFmt(SFOpenError + LineEnding + mbSysErrorMessage , [AFilename])
@@ -213,11 +213,26 @@ function TFileStreamEx.Write(const Buffer; Count: LongInt): LongInt;
213213{ TStringListEx }
214214
215215function TStringListEx.DoCompareText (const S1, S2: String): PtrInt;
216+ var
217+ U1, U2: UnicodeString;
216218begin
219+ U1:= CeUtf8ToUtf16(S1);
220+ U2:= CeUtf8ToUtf16(S2);
221+
217222 if CaseSensitive then
218- Result:= UTF8CompareStr(S1, S2)
223+ begin
224+ Result:= UnicodeCompareStr(U1, U2);
225+ if Result = 0 then
226+ begin
227+ Result := CompareMemRange(Pointer(U1), Pointer(U2), Min(Length(U1), Length(U2)) * SizeOf(WideChar));
228+ if Result = 0 then
229+ Result := Length(U1) - Length(U2);
230+ end
231+ end
219232 else
220- Result:= UTF8CompareText(S1, S2);
233+ begin
234+ Result:= UnicodeCompareText(U1, U2);
235+ end ;
221236end ;
222237
223238function TStringListEx.IndexOfValue (const Value : String): Integer;
0 commit comments