Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Ascii Table
by repson (Chaplain) on Nov 29, 2000 at 08:42 UTC
    Since this is a perl site you could always do something like:
    perl -e 'printf("%.3d -> %s\n", $_, chr($_)) for (32..255)'
Re: Ascii Table
by jgallagher (Pilgrim) on Nov 29, 2000 at 07:09 UTC
Re: Ascii Table
by t0mas (Priest) on Nov 29, 2000 at 12:41 UTC
    I use the following little script:
    #!/usr/bin/perl -w use HTML::Entities; @chr=qw(NUL SOH STX ETX EOT ENQ ACK BEL BS HT NL VT NP CR SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US SP); printf("DEC\tHEX\tOCT\tBIN \tCHR\tHTML\n"); printf("---\t---\t---\t--------\t---\t----\n"); for (0..255) { printf("%.3u\t%.2x\t%.3o\t%.8b\t%s\t%s\n", $_,$_,$_,$_,$_<33?$chr[$_]:chr($_),$_<33?"":encode_entities(chr($_ +))); }
    Prints ascii characters or mnemonics, dec,hex,oct and bin values plus the html encoded value.

    /brother t0mas
      Hmm. I'm getting an invalid conversion on the %b...
        The %b conversion for printf wasn't added until perl5.6.0. For earlier versions, you can convert decimal to binary with pack and unpack:
        $binary = unpack 'B*', pack 'N', $decimal; $binary =~ s/^0+//;
        Strange...
        Can you do any %b conversions at all?
        Like perl -e "printf('%b",20');" ?

        /brother t0mas
Re: Ascii Table
by extremely (Priest) on Nov 29, 2000 at 08:09 UTC
    if you are on a unix box, try man ascii Under windows, look for the START:Programs:Accessories:System_Tools:Character_Map application. If you have newer versions make sure to hit the Advanced checkbox...

    --
    $you = new YOU;
    honk() if $you->love(perl)

Re: Ascii Table
by Fastolfe (Vicar) on Nov 29, 2000 at 07:27 UTC
    Uhh, did you try doing a netsearch? Hitting up Google gave me a freakin' pageful of relevant links.
Re: Ascii Table
by Anonymous Monk on Nov 29, 2000 at 08:46 UTC
      Feh to that. =) `man ascii` rocks. =P I've been tempted to modify the Linux one so that it would have perl escapes as well as C ones... might be handy someday.

      --
      $you = new YOU;
      honk() if $you->love(perl)