Compare Case Sensitive OR Case Insensitive Mixed String?

General TRichView support forum. Please post your questions here
Post Reply
DickBryant
Posts: 148
Joined: Wed Dec 07, 2005 2:02 pm
Contact:

Compare Case Sensitive OR Case Insensitive Mixed String?

Post by DickBryant »

I'm using GetRVDataText to get the text from two variables of type TRVTableCellData. Depending on option settings I want to compare them in either case sensitive or case insensitive fashion, and be able to support unicode characters in the text.

This code works for non-Unicode strings :

if CaseSensitive then
begin //Do case-sensitive compare
if CompareStr(GetRVDataText(PQAURec^.MCFillIn1),GetRVDataText(PMiscRec^.MyAnswer)) = 0 then
Do Stuff
end
else
begin //Do case-insensitive compare
if CompareText(GetRVDataText(PQAURec^.MCFillIn1),GetRVDataText(PMiscRec^.MyAnswer)) = 0 then
Do Stuff
end;

What is the proper approach to be able to handle the text returned from GetRVDataText which can/will include Unicode characters (the control is set to rvuMixed.
DickBryant
Posts: 148
Joined: Wed Dec 07, 2005 2:02 pm
Contact:

Post by DickBryant »

Solved this myself - it appears that the Delphi WideCompareText and WideCompareStr will handle this task.

Please see my newer question, though - I'm at a loss on that one.

Thanks!
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Ok, but, as far as I know, capitalizing Unicode text is a tricky task, because the result may depend on the text language (which is unknown)
What's why, I think, the help file for this function states: "The compare operation is controlled by the current locale". So in some cases the results may be different on different computers.
Just FYI.
DickBryant
Posts: 148
Joined: Wed Dec 07, 2005 2:02 pm
Contact:

Post by DickBryant »

Thanks for the additional info, Sergey. In almost all instances, though, the two strings will have been created in the the same locale - hence the check to see whether they are identical in the case sensitive mode should be valid.
Post Reply