Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Convert latin-1 characters to named HTML entities?

Reply
Thread Tools

Convert latin-1 characters to named HTML entities?

 
 
Joergen Bech
Guest
Posts: n/a
 
      06-13-2005

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/a...s/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



 
Reply With Quote
 
 
 
 
Joerg Jooss
Guest
Posts: n/a
 
      06-13-2005
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/a...e/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
(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Joergen Bech
Guest
Posts: n/a
 
      06-14-2005
On Mon, 13 Jun 2005 13:25:41 -0700, "Joerg Jooss"
<(E-Mail Removed)> 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/a...e/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-page...ntities.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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: convert unicode characters to visibly similar ascii characters Laszlo Nagy Python 6 07-02-2008 04:42 PM
Re: convert unicode characters to visibly similar ascii characters M.-A. Lemburg Python 0 07-02-2008 08:39 AM
Re: convert unicode characters to visibly similar ascii characters Terry Reedy Python 0 07-01-2008 07:46 PM
How to convert HTML special characters to the real characters with a Java script Stefan Mueller HTML 3 07-23-2006 10:09 PM
Convert Raw Text Escaped Characters to Characters nicholas.wakefield@gmail.com Java 2 07-11-2005 09:17 PM



Advertisments