string comparison

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
 
M

Mark Ashton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

strings comparison 1

Top