|
Posted by Bill H on October 16, 2008, 7:10 pm
Please log in for more thread options >
>
>
>
>
> > Bill H wrote:
> > > I am using the following code to unescape html text that is coming
> > > from flash:
>
> > > sub unescape
> > > {
> > > =A0 =A0 my $text =3D shift;
> > > =A0 =A0 $text =3D~ s/%(..)/pack("c",hex($1))/ge;
> > > =A0 =A0 return($text);
> > > }
>
> > > for example it will take this text:
>
> > > %3CFONT%20FACE%3D%22timesnewroman%22%20COLOR%3D%22#000000%22%20SIZE%3=
D
> > > %2220%22%3E%3CP%20ALIGN%3D%22CENTER%22%3EChapter%20Title%3C%2FP%3E%3C
> > > %2FFONT%3E
>
> > > and it will convert it to this:
>
> > > <FONT FACE=3D"timesnewroman" COLOR=3D"#000000" SIZE=3D"20"><P
> > > ALIGN=3D"CENTER">Chapter Title</P></FONT>
>
> > > What I am trying to figure out is how to go the other way in perl,
> > > convert the html to an escaped format. Any hints, clues, pointers
> > > would be appreciated
>
> > > Bill H
>
> > Just don't run the input through the unescape sub routine (or have one
> > that does and another that doesn't (and do whatever you want with the
> > other))? =A0Or am I misunderstanding your problem/question?
> > --
> > Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
> > Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
> > and Custom Hosting. =A024/7 support, 30 day guarantee, secure servers.
> > Industry's most experienced staff! -- Web Hosting With Muscle!- Hide qu=
oted text -
>
> > - Show quoted text -
>
> Tim
>
> Actually the problem is that I want to use perl to make a lot of
> default "escaped" html for flash. Up till now I have been just using
> flash to do it, but now I have about 60 templates that I need to
> create and know there has to be a better way then code actionscript,
> run flash, cut / paste escaped stuff into perl code, run perl to
> create template, repeat.
>
> I was thinking of using HTML::Entities, but I can't install it on the
> server I am using.
>
> Bill H- Hide quoted text -
>
> - Show quoted text -
The other thought I had, the brute force approach, is to just escape
every character in the string (ie convert each character to a %??). I
suppose I could get a little creative and not touch any numbers or
letters, just everything below ascii 48, above ascii 57 and below
ascii 65. Above ascii 90 and below ascii 97, and above ascii 122.
Wonder if there is a regex that could do this for me?
Bill H
|