in reply to Printing octal characters

Well the oct($str) function will take an octal string $str into decimal and return the value; Then you can print chr(oct($str))." ".$str so print the charcter that corresponds with the decimal value of the octal code. Sort of non intuitive though. Try this:
foreach ( 0200.. 0377) { print chr(oct($_))." ".$_."\n"; }
(WARNING: this will give some bogus results and or fail becasuse I was asleep when I wrote it ... see the replies)

Replies are listed 'Best First'.
RE: Re: Printing octal characters
by btrott (Parson) on Apr 25, 2000 at 22:42 UTC
    No, that doesn't work. The octal numbers in the foreach loop are converted into decimal internally, so within the loop $_ is actually in decimal, not octal. So you don't need the oct function. In fact, putting in the oct function is wrong, and it will give you errors ("Illegal octal digit ignored ...").

    You can tell by looking at what $_ prints out in your print statement. So you really just need

    print chr $_;
      Doh, you are quite correct. Sorry.

      To print out every possble character this should do it:
      foreach (0 .. 255) { print chr($_)." $_\n"; }
      So to print out the oct 277 you can do "print chr(oct(277))"

      I think I am correct this time.