Replace HTML chars above ASCII 127

I have to use some html generated by MS Word.

Some of the text contains characters that are greater than ASCII 127 and show up as question marks � in browsers.

I can replace these but do not know what to look for in the HTML.

Example C# code: thisHtml = thisHtml.Replace("&#160", "&nbsp");  // this does not work

I need something that will replace all the characters showing up as question marks with the html equivalent please.

BTW, I cannot change the charset.

Thanks
NDennisVAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
If you are going to do this server side, I think your code reads, replace old value with new value.  Are you sure the output is &#160?  What if you tried thisHtml.Replace(" ", "&nbsp"); or thisHtml.Replace((chr)160, "&nbsp");
0
NDennisVAuthor Commented:
I'm working on my PC at home.

That is part of my question. How do I know what the output is that is causing the question marks.
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I found this article from Ray very helpful http://iconoun.com/articles/collisions/.  I do not know c# very well but it appears there is a conversion similar to what Ray points out in php  https://msdn.microsoft.com/en-us/library/system.text.encoding.utf8%28v=vs.110%29.aspx

Instead of replacing each character, perhaps you can replace the output.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NDennisVAuthor Commented:
I am currently replacing all the question marks with   and it works. But that's assuming they are all white space characters.

I think I can get something useful out of the MS link so I will award the points.

Thanks
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I wouldn't rely on just one character as I mentioned.  If you only test for one, there will be another.  You will want to convert it as you generate html from your c# code.  In that sample where they show

Encoding enc = new UTF8Encoding(true, true);
      string value = "\u00C4 \uD802\u0033 \u00AE"; 

Open in new window


You will simply replace "\u00C4 \uD802\u0033 \u00AE" with the output from your database.  I'm sorry I don't work in C to be able to give you better details.  The key is to just convert everything.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.