Convert latin-1 characters to named HTML entities?

Discussion in 'ASP .Net' started by Joergen Bech, Jun 13, 2005.

  1. Joergen Bech

    Joergen Bech Guest

    Is there a function in the .Net 1.1 framework
    that will take, say, a string containing Scandinavian
    characters and output the corret HTML entities, such
    as

    æ
    ø
    å

    etc.

    I am currently using FreeTextBox, but while it seems to
    convert some characters (<, >, ...), others are left alone
    and need to be converted separately.

    I cannot use Response.Write or similar: I am taking freeform
    input from FreeTextBox and normal textboxes and creating
    static HTML files for later use, using String.Replace.

    Basically, I need something that will convert the first column
    to the third in
    http://msdn.microsoft.com/workshop/author/dhtml/reference/charsets/charset1.asp
    but if there is already something in the framework for this purpose
    I would feel silly writing my own (probably slower) function.

    TIA,

    Joergen Bech
     
    Joergen Bech, Jun 13, 2005
    #1
    1. Advertising

  2. Joergen Bech

    Joerg Jooss Guest

    Joergen Bech wrote:

    >
    > Is there a function in the .Net 1.1 framework
    > that will take, say, a string containing Scandinavian
    > characters and output the corret HTML entities, such
    > as
    >
    > &aelig;
    > &oslash;
    > &aring;
    >
    > etc.
    >
    > I am currently using FreeTextBox, but while it seems to
    > convert some characters (<, >, ...), others are left alone
    > and need to be converted separately.
    >
    > I cannot use Response.Write or similar: I am taking freeform
    > input from FreeTextBox and normal textboxes and creating
    > static HTML files for later use, using String.Replace.
    >
    > Basically, I need something that will convert the first column
    > to the third in
    > http://msdn.microsoft.com/workshop/author/dhtml/reference/charsets/cha
    > rset1.asp but if there is already something in the framework for this
    > purpose I would feel silly writing my own (probably slower) function.


    Do you really need character references, or will numeric references
    work for you as well (they should)?

    System.Web.HttpUtility.HtmlEncode() and
    System.Web.HttpServerUtility.HtmlEncode() (which calls the other one)
    do that trick. You may find though that the encoded output uses both
    character and numeric references (see http://tinyurl.com/9bq6g).

    Cheers,
    --
    http://www.joergjooss.de
    mailto:
     
    Joerg Jooss, Jun 13, 2005
    #2
    1. Advertising

  3. Joergen Bech

    Joergen Bech Guest

    On Mon, 13 Jun 2005 13:25:41 -0700, "Joerg Jooss"
    <> wrote:

    >Joergen Bech wrote:
    >
    >>
    >> Is there a function in the .Net 1.1 framework
    >> that will take, say, a string containing Scandinavian
    >> characters and output the corret HTML entities, such
    >> as
    >>
    >> &aelig;
    >> &oslash;
    >> &aring;
    >>
    >> etc.
    >>
    >> I am currently using FreeTextBox, but while it seems to
    >> convert some characters (<, >, ...), others are left alone
    >> and need to be converted separately.
    >>
    >> I cannot use Response.Write or similar: I am taking freeform
    >> input from FreeTextBox and normal textboxes and creating
    >> static HTML files for later use, using String.Replace.
    >>
    >> Basically, I need something that will convert the first column
    >> to the third in
    >> http://msdn.microsoft.com/workshop/author/dhtml/reference/charsets/cha
    >> rset1.asp but if there is already something in the framework for this
    >> purpose I would feel silly writing my own (probably slower) function.

    >
    >Do you really need character references, or will numeric references
    >work for you as well (they should)?
    >
    >System.Web.HttpUtility.HtmlEncode() and
    >System.Web.HttpServerUtility.HtmlEncode() (which calls the other one)
    >do that trick. You may find though that the encoded output uses both
    >character and numeric references (see http://tinyurl.com/9bq6g).
    >
    >Cheers,


    Thanks. I'll try. Trouble is, I would like everything to be named
    html entities (for other reasons). I'll have to use HTMLEncode if a
    few custom string replacements turn out to insufficient.

    Sure am surprised, though, that it seems so hard to find a
    function for this purpose (in .Net). Something like:
    http://maconlinux.net/linux-man-pages/en/HTML::Entities.3.html

    The Microsoft.SharePoint.Utilities.SPEncode class sounds useful,
    but not to me, as this is not a SharePoint application.

    I'll have to investigate the possibilities later.

    Regards,

    Joergen Bech
     
    Joergen Bech, Jun 14, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ulrice jardin
    Replies:
    1
    Views:
    447
    Kent Johnson
    Jul 27, 2005
  2. Guest
    Replies:
    2
    Views:
    767
    Guest
    Jun 20, 2007
  3. Mangler

    HTML Named/Number Entities

    Mangler, Nov 27, 2008, in forum: HTML
    Replies:
    10
    Views:
    891
    Mangler
    Nov 28, 2008
  4. Jim Higson
    Replies:
    3
    Views:
    235
    Eric Amick
    Jul 25, 2004
  5. Stefan Mueller
    Replies:
    3
    Views:
    210
    Stefan Mueller
    Mar 21, 2006
Loading...

Share This Page