Connecting Tech Pros Worldwide Help | Site Map

convert special characters

Frederik
Guest
 
Posts: n/a
#1: Nov 16 '05
Hi all,

I wonder if C# has a build-in utility to convert special characters
(for example "&", "<", ">") to the corresponding html entities. If
such a utility is not available, can someone tell me what to do best
to make the conversion (regular expressions?).

Thanx in advance,
Frederik
Shiva
Guest
 
Posts: n/a
#2: Nov 16 '05

re: convert special characters


Hi,

Is System.Web.HttpUtility.HtmlEncode() what you are looking for?


"Frederik" <aerts_frederik@hotmail.com> wrote in message
news:97271183.0407240929.6ea51163@posting.google.c om...
Hi all,

I wonder if C# has a build-in utility to convert special characters
(for example "&", "<", ">") to the corresponding html entities. If
such a utility is not available, can someone tell me what to do best
to make the conversion (regular expressions?).

Thanx in advance,
Frederik


Frederik
Guest
 
Posts: n/a
#3: Nov 16 '05

re: convert special characters


> Is System.Web.HttpUtility.HtmlEncode() what you are looking for?

Hi Shiva,

That method seems to be useful, but I can't use it!!! The namespace can't be
found when compiling. Any idea why? I'm using Visual Studio 2003 and I'm
working on a Win32 application.

Regards,
Frederik
[color=blue]
> Hi all,
> I wonder if C# has a build-in utility to convert special characters
> (for example "&", "<", ">") to the corresponding html entities. If
> such a utility is not available, can someone tell me what to do best
> to make the conversion (regular expressions?).
> Thanx in advance,
> Frederik[/color]


Magnus Krisell
Guest
 
Posts: n/a
#4: Nov 16 '05

re: convert special characters


Add a reference to the System.Web assembly.
(Right-click on References in Solution Explorer and select Add Reference.)

- Magnus

"Frederik" <aerts_frederik@hotmail.com> wrote in message
news:eKGDzcicEHA.3512@TK2MSFTNGP12.phx.gbl...[color=blue][color=green]
> > Is System.Web.HttpUtility.HtmlEncode() what you are looking for?[/color]
>
> Hi Shiva,
>
> That method seems to be useful, but I can't use it!!! The namespace can't[/color]
be[color=blue]
> found when compiling. Any idea why? I'm using Visual Studio 2003 and I'm
> working on a Win32 application.
>
> Regards,
> Frederik
>[color=green]
> > Hi all,
> > I wonder if C# has a build-in utility to convert special characters
> > (for example "&", "<", ">") to the corresponding html entities. If
> > such a utility is not available, can someone tell me what to do best
> > to make the conversion (regular expressions?).
> > Thanx in advance,
> > Frederik[/color]
>
>[/color]


Shiva
Guest
 
Posts: n/a
#5: Nov 16 '05

re: convert special characters


Yes, as Magnus suggested, add a reference to System.Web.dll.

"Frederik" <aerts_frederik@hotmail.com> wrote in message
news:eKGDzcicEHA.3512@TK2MSFTNGP12.phx.gbl...[color=blue]
> Is System.Web.HttpUtility.HtmlEncode() what you are looking for?[/color]

Hi Shiva,

That method seems to be useful, but I can't use it!!! The namespace can't be
found when compiling. Any idea why? I'm using Visual Studio 2003 and I'm
working on a Win32 application.

Regards,
Frederik
[color=blue]
> Hi all,
> I wonder if C# has a build-in utility to convert special characters
> (for example "&", "<", ">") to the corresponding html entities. If
> such a utility is not available, can someone tell me what to do best
> to make the conversion (regular expressions?).
> Thanx in advance,
> Frederik[/color]



Frederik
Guest
 
Posts: n/a
#6: Nov 16 '05

re: convert special characters


> Add a reference to the System.Web assembly.[color=blue]
> (Right-click on References in Solution Explorer
> and select Add Reference.)[/color]
[color=blue]
> Yes, as Magnus suggested, add a reference to System.Web.dll.[/color]

Thanx Magnus and Shiva! It runs fine now! :-))


Closed Thread