Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4554846
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:08:32+00:00 2026-05-21T17:08:32+00:00

I have html encoded strings in a database, but many of the character entities

  • 0

I have html encoded strings in a database, but many of the character entities are not just the standard & and <. Entities like “ and —. Unfortunately we need to feed this data into a flash based rss reader and flash doesn’t read these entities, but they do read the unicode equivalent (ex “).

Using .Net 4.0, is there any utility method that will convert the html encoded string to use unicode encoded character entities?

Here is a better example of what I need. The db has html strings like: <p>John &amp; Sarah went to see $ldquo;Scream 4$rdquo;.</p> and what I need to output in the rss/xml document with in the <description> tag is: &lt;p&gt;John &amp;#38; Sarah went to see &amp;#8220;Scream 4&amp;#8221;.&lt;/p&gt;

I’m using an XmlTextWriter to create the xml document from the database records similar to this example code http://www.dotnettutorials.com/tutorials/advanced/rss-feed-asp-net-csharp.aspx

So I need to replace all of the character entities within the html string from the db with their unicode equivilant because the flash based rss reader doesn’t recognize any entities beyond the most common like &amp;.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:08:33+00:00Added an answer on May 21, 2026 at 5:08 pm

    My first thought is, can your RSS reader accept the actual characters? If so, you can use HtmlDecode and feed it directly in.

    If you do need to convert it to the numeric representations, you could parse out each entity, HtmlDecode it, and then cast it to an int to get the base-10 unicode value. Then re-insert it into the string.

    EDIT:
    Here’s some code to demonstrate what I mean (it is untested, but gets the idea across):

    string input = "Something with &mdash; or other character entities.";
    StringBuilder output = new StringBuilder(input.Length);
    
    for (int i = 0; i < input.Length; i++)
    {
        if (input[i] == '&')
        {
            int startOfEntity = i; // just for easier reading
            int endOfEntity = input.IndexOf(';', startOfEntity);
            string entity = input.Substring(startOfEntity, endOfEntity - startOfEntity);
            int unicodeNumber = (int)(HttpUtility.HtmlDecode(entity)[0]);
            output.Append("&#" + unicodeNumber + ";");
            i = endOfEntity; // continue parsing after the end of the entity
        }
        else
            output.Append(input[i]);
    }
    

    I may have an off-by-one error somewhere in there, but it should be close.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have email addresses encoded with HTML character entities. Is there anything in .NET
I have a string that is HTML encoded: '''&lt;img class=&quot;size-medium wp-image-113&quot;\ style=&quot;margin-left: 15px;&quot; title=&quot;su1&quot;\
I have a string returned from server with encoded HTML tags. I use the
I have a html text. I had encoded it in php using urlencode function.
I have a list of html pages which may contain certain encoded characters. Some
I have html code that looks roughly like this: <div id=id1> <div id=id2> <p>some
I have an html box with which users may enter text. I would like
I have two issues When I submit the character ' through my HTML form
I have an HTML file (encoded in utf-8). I open it with codecs.open() .
I have to encode strings to remove parentheses for Ids for HTML elements. Parentheses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.