replacing strange characters pulled from db field

  • Thread starter Thread starter vtxr1300
  • Start date Start date
V

vtxr1300

I have a description field where people are putting in all kinds of non
html characters. When they're being pulled from the db, they're coming
out like • or  or any number of things. Does anyone have
a C# function written that would fix these? It's for a C# v1 project,
not v2. Thanks.
 
vtxr1300,

Use the static HtmlEncode and HtmlDecode methods on the HttpUtility
class in the System.Web namespace, located in System.Web.dll.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I have a description field where people are putting in all kinds of non
html characters. When they're being pulled from the db, they're coming
out like â?¢ or  or any number of things. Does anyone have
a C# function written that would fix these? It's for a C# v1 project,
not v2. Thanks.
 
vtxr1300 said:
I have a description field where people are putting in all kinds of non
html characters. When they're being pulled from the db, they're coming
out like â?¢ or  or any number of things. Does anyone have
a C# function written that would fix these? It's for a C# v1 project,
not v2. Thanks.

First you need to identify where the problem is.

See http://www.pobox.com/~skeet/csharp/debuggingunicode.html
 
Nicholas said:
vtxr1300,

Use the static HtmlEncode and HtmlDecode methods on the HttpUtility
class in the System.Web namespace, located in System.Web.dll.

Hope this helps.
I originally tried that, but it also encoded all of the html formatting
that was in the string. I need to preserve that. I'll look at Jon's
recommendation and see if I can make sense of that. Thanks.
 

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

Back
Top