Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

foreign character comparison problem

Status
Not open for further replies.

Jimi2Cool

Programmer
Jul 30, 2007
25
0
0
US
OK. i have a method that looks through a list of strings to find matches to user input. for instance the list contains these 2 entries

As, Aš

if i user types As id like to grab both entries.

I've been trying things with string.Compair to ignore culture and what not but no matter what i do i cant seem to tell .net i want it to treat these the same. is there a way to do this? or is there a way i can convert Aš to As before i compaire?

 
hmm, well, i think i found the solution that works in my case.

something like this works the way i need it

---------------------------------------
static System.Globalization.CompareInfo compareinf = System.Globalization.CompareInfo.GetCompareInfo("en-us");

string s = compareto.SubString(0,startwith.Length);

if (compareinf.Compare(s, startswith, System.Globalization.CompareOptions.IgnoreNonSpace | System.Globalization.CompareOptions.IgnoreCase) == 0)
{
//do something
}
-------------------------------

Apparently the System.Globalization.CompareOptions.IgnoreNonSpace flag is needed in my case.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top