string comparison

  • Thread starter Thread starter Dariusz Tomon
  • Start date Start date
D

Dariusz Tomon

Hello

I'm trying to compare two strings:

1. retrieved from custom xmlplaceholder (Microsoft CMS):
zrodlo = fact.Placeholders["kategoria2"] as XmlPlaceholder;

esc_kat2 = Server.HtmlEncode(zrodlo.XmlAsString);

esc_kat2 = esc_kat2.Replace("<","");

esc_kat2 = esc_kat2.Replace(">","");

esc_kat2 = esc_kat2.Replace("/Zones","");

esc_kat2 = esc_kat2.Replace("/Zone","");

esc_kat2 = esc_kat2.Replace("Zones","");

kategoria2 = esc_kat2.Replace("Zone","");


String kategoria2 has my nationals characters translated into unicode and
looks like this:

"orzecznictwo do celów pozarentowych"

2. The second one is retrieved from SQL database:

selectCmd = "select * from urzond_main order by id";

myCommand = new SqlCommand(selectCmd, myConnection);

myConnection.Open();

myReader = myCommand.ExecuteReader();



while (myReader.Read())

{

kategoria1 = myReader.GetSqlString(1).ToString();

}



String kategoria1 has original national characters without being
translated into unicode:

orzecznictwo do celów pozarentowych



I cannot compare these strings 'cos they are different.

What is the best advice? Please give some code portion with an advice.

Best Regards



Darek
 
Both strings are unicode, it looks like kategoria2 was encoded for html.
Try using the HtmlDecode method on the string to have the ó reverted
back to the ó character.
 
Back
Top