Avatar of DickStone
DickStone
 asked on

String compare on non-English names?

In Visual C++, how do I compare two names so that French characters are the same as their English equivalent.

For example, "Bélanger" should compare equal to "Belanger". Or "Coût" compares equial to "Cout".

I used to use CString1.Collate(CString2) in an older version of MS Visual Studio C++, but it no longer seems to work.
System ProgrammingVisual C++.NET

Avatar of undefined
Last Comment
AndyAinscow

8/22/2022 - Mon
SOLUTION
AndyAinscow

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
DickStone

ASKER
I didn't need setlocale(LC_ALL,"French") before.I also didn't need CAtlString before.

I just tried turning on setlocale. It appears to screw up lots of other stuff -- even to the point of causing an infinite loop. It doesn't seem to be a solution to making "Bélanger"and "Belanger" equivalent.

It appears that Collate worked before, but no longer does without it, though.

Any good ideas? Maybe I should write a CollateNoFrench() that replaces the French characters before calling Collate?
ASKER CERTIFIED SOLUTION
AndyAinscow

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
DickStone

ASKER
The good news is that it this works!

The bad news is that it's about 5 times as slow as converting strings (change "é" to "e", and "û" to "ut" and etc.) and then doing a normal Compare. I wrote a little function to do this.

Of course, the speed isn't your fault -- your answer is great  and I'll use it in the future when I'm not doing about 10,000 compares (as in this particular case).

)
AndyAinscow

:-)

Thanks for the feedback re performance.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck