Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2013-10

How to check why WideStringCompare fails?

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin
It seems for some people using 2.7.1
     FCurrentString: string;

if 0 = WideCompareText(UTF8Decode(fCurrentString), UTF8Decode(Copy(ItemList[i], 1,
Length(fCurrentString))))

does not compare correct.
http://bugs.freepascal.org/view.php?id=25156

How can they best check if this is:
- an issue with their setup, maybe widestringmanager failing.
- an issue with UTF8Decode
-- maybe because the encoding of FCurrentString?

Though I wonder which encoding FCurrentString could have an their system, to fail latin a-z letters from being correctly converted?

Reply by email

ko paka
to Martin

I had similar issue when use fpc 2.7.1 r25610. I have application on linux with cwstring manager, but same error was aswell on windows. When I used ANSICompareStr and as parameters sent 2 unicode strings, result was always
0. What I observed - because parameters of ANSICompareStr are ansi strings, 2 calls of fpc_UnicodeStr_To_AnsiStr was made before enter into ANSICompareStr. In first call was Result of fpc_UnicodeStr_To_AnsiStr on begin nil - OK. But in second call was Result of fpc_UnicodeStr_To_AnsiStr on begin not nil - which is not OK and caused free of previously translated string and create second string on its place. Because of this, ANSICompareStr both parameters pointed to one memory location and so result of ANSICompareStr was always 0.
In fpc 2.7.1 r25725 this problem exists never more.

tomas

Martin wrote 24 lines
It seems for some people using 2.7.1 FCurrentString: string; if 0 = WideCompareText(UTF8Decode(**fCurrentString), UTF8Decode(Copy(ItemList[i], 1, Length(fCurrentString)))) does not compare correct. http://bugs.freepascal.org/**view.php?id=25156<http://bugs.freepascal.org/view.php?id=25156> How can they best check if this is: - an issue with their setup, maybe widestringmanager failing. - an issue with UTF8Decode -- maybe because the encoding of FCurrentString? Though I wonder which encoding FCurrentString could have an their system, to fail latin a-z letters from being correctly converted? ______________________________**_________________ fpc-devel maillist - http://lists.freepascal.org/**mailman/listinfo/fpc-devel<http://lists.freepascal.org/mailman/listinfo/fpc-devel>

Reply by email

Jonas Maebe
to Martin: It seems for some people using 2.7.1 FCurrentString: string; if 0 =…
Martin wrote 12 lines
It seems for some people using 2.7.1 FCurrentString: string; if 0 = WideCompareText(UTF8Decode(fCurrentString), UTF8Decode(Copy(ItemList[i], 1, Length(fCurrentString)))) does not compare correct. http://bugs.freepascal.org/view.php?id=25156 How can they best check if this is: - an issue with their setup, maybe widestringmanager failing.

If it's not one of the two other issues, it's probably the widestring manager.

- an issue with UTF8Decode

Look at the the contents of fCurrentString and at the result of UTF8Decode.

-- maybe because the encoding of FCurrentString?

Look at the result of StringCodePage(fCurrentString).

Jonas

Reply by email