Loading ...
Sorry, an error occurred while loading the content.

How to convert to ascii

Expand Messages
  • Gilles Beauregard
    Allo! How to convert the following string to regular ascii: mailto:we Have a nice and spam free day. Gilles B. --
    Message 1 of 6 , May 31, 2004
    View Source
    • 0 Attachment
      Allo!

      How to convert the following string to regular ascii:

      mailto:we

      Have a nice and spam free day.

      Gilles B.
      --
      Encore plus de trucs et d'astuces pour Webmasters
      http://www.biwi.qc.ca/favori/
      More Webmastering trics:
      http://www.biwi.qc.ca/favorite/
      --
    • Paul Archer
      ... Look at chr (and it s opposite, ord). But that looks like HTML encoding (to my non-web master/developer eye). So my guess is there s a subrouting in the
      Message 2 of 6 , May 31, 2004
      View Source
      • 0 Attachment
        10:11am, Gilles Beauregard wrote:

        > Allo!
        >
        > How to convert the following string to regular ascii:
        >
        > mailto:we
        >
        Look at chr (and it's opposite, ord). But that looks like HTML encoding (to
        my non-web master/developer eye). So my guess is there's a subrouting in the
        CGI module that'll do what you want.



        ---------------------------------------------
        There are two major products that come out of
        Berkeley: LSD and UNIX. We don't believe this
        to be a coincidence. - Jeremy S. Anderson
        ---------------------------------------------
      • daymobrew@yahoo.com
        ... encoding (to ... subrouting in the ... There is an escapeHTML() function in CGI.pm but I didn t find a reversal function. As Paul suggests, chr() will
        Message 3 of 6 , Jun 1, 2004
        View Source
        • 0 Attachment
          --- In perl-beginner@yahoogroups.com, Paul Archer <tigger@i...> wrote:
          > 10:11am, Gilles Beauregard wrote:
          >
          > > Allo!
          > >
          > > How to convert the following string to regular ascii:
          > >
          > > mailto:we
          > >
          > Look at chr (and it's opposite, ord). But that looks like HTML
          encoding (to
          > my non-web master/developer eye). So my guess is there's a
          subrouting in the
          > CGI module that'll do what you want.
          >

          There is an escapeHTML() function in CGI.pm but I didn't find a
          reversal function.
          As Paul suggests, chr() will convert 109 to 'm'
          So, maybe you could split the string on semi-colons, strip off the
          '&#' and then run through chr().
        • Jenda Krynicky
          From: daymobrew@yahoo.com ... And what will you do if there are some unescaped chars? Use regexp replacement instead: $string =~ s/& #( d+);/chr($1)/ge; or
          Message 4 of 6 , Jun 1, 2004
          View Source
          • 0 Attachment
            From: daymobrew@...
            > --- In perl-beginner@yahoogroups.com, Paul Archer <tigger@i...> wrote:
            > > 10:11am, Gilles Beauregard wrote: > > > Allo! > > > > How to convert
            > the following string to regular ascii: > > > >
            > mailto:we > > > Look at chr
            > (and it's opposite, ord). But that looks like HTML encoding (to > my
            > non-web master/developer eye). So my guess is there's a subrouting in
            > the > CGI module that'll do what you want. >
            >
            > There is an escapeHTML() function in CGI.pm but I didn't find a
            > reversal function.
            > As Paul suggests, chr() will convert 109 to 'm'
            > So, maybe you could split the string on semi-colons, strip off the
            > '&#' and then run through chr().

            And what will you do if there are some unescaped chars?

            Use regexp replacement instead:

            $string =~ s/&\#(\d+);/chr($1)/ge;

            or even better, use a module:

            use HTML::Entities;
            $string = decode_entities($string);

            that way you can be sure even á and ø type entities are
            handled correctly.

            Jenda
            ===== Jenda@... === http://Jenda.Krynicky.cz =====
            When it comes to wine, women and song, wizards are allowed
            to get drunk and croon as much as they like.
            -- Terry Pratchett in Sourcery
          • Dustin Davis
            Is there an equivilent command in perl as the php include function (basically includes another script as if it were a part of the script including it)
            Message 5 of 6 , Jun 1, 2004
            View Source
            • 0 Attachment
              Is there an equivilent command in perl as the php include function
              (basically includes another script as if it were a part of the script
              "including" it)

              Thanks,
              Dustin
            • Gilles Beauregard
              Allo! ... Work great! Thank! Gilles B. -- Encore plus de trucs et d astuces pour Webmasters http://www.biwi.qc.ca/favori/ More Webmastering trics:
              Message 6 of 6 , Jun 1, 2004
              View Source
              • 0 Attachment
                Allo!

                >Use regexp replacement instead:
                >
                > $string =~ s/&\#(\d+);/chr($1)/ge;
                >
                >or even better, use a module:
                >
                > use HTML::Entities;
                > $string = decode_entities($string);

                Work great!

                Thank!

                Gilles B.

                --
                Encore plus de trucs et d'astuces pour Webmasters
                http://www.biwi.qc.ca/favori/
                More Webmastering trics:
                http://www.biwi.qc.ca/favorite/
                --
              Your message has been successfully submitted and would be delivered to recipients shortly.