c# - How does html decoding work? -
in app compare strings. have strings same of them contain white space, , other contain nbsp, when compare them different. however, represent same entity have issues when compare them. that's why want decode strings compare. way nbsp converted space in both of strings , treated equal when comparison. here's do:
httputility.htmldecode(string1)[0] httputility.htmldecode(string2)[0]
but still string1[0] has ascii code of 160, , string2[0] has ascii code of 32.
obviously not understanding concept. doing wrong?
you trying compare 2 different characters, no matter how resembling might seem you.
the fact have different character codes enough make comparison fail. easiest thing replace non-breaking space regular space , compare them.
bool c = html.replace('\u00a0', ' ').equals(regular);
Comments
Post a Comment