PDA

View Full Version : when and where do we need octal code?



james438
09-03-2008, 08:24 PM
I think this is the best place for this question. I have used octal code on occasion when nothing else seemed to work, but I am not sure when or why that was.

In short: when and where is octal code useful? specifically in regards to php users like myself.

Twey
09-04-2008, 03:37 AM
Octal? Erm... when you're dealing with data separated at the eight-bit. Notably, *nix usually uses an octal representation for its permissions, where each digit is a bitset of 1 (execute), 2 (write), and 4 (read).

james438
09-04-2008, 06:13 AM
interesting. I didn't realize that chmod permissions used octal code. Seems obvious now, but I don't really deal with permissions very much.

The following is just a test for now.

test
       test
\040\040\040\040\\040\\040;\\040test
������������test
test


test
       test
\040\040\040\040\\040\\040;\\040test]
������������test
test

dunno what this is, but take a sneak peak at this lil script I wrote :)

<?php
$b="�";
$a=0;
while ($a<200)
{$b="$b$a";$b.=";";
echo"$b$b$b$b=&amp;#0$a;<br>";$b="�";$a++;}
?>

I even ran the above code with 20000 instead of 200 in the while loop for even more interesting results. Becareful though, because if you set it to 20000 as opposed to 200 the file was 1mb in size.

What did I just write? it doesn't look like octal, binary or even hex to me. I use all three very infrequently, but enough to have some idea of what they look like at least.

In the tests above I tried typing out & # 0 4 0 ; (without the spaces), but it just came out looking like ( instead. In place of the "�" symbol above I used " & # 0 " (again without spaces).

I dare not edit this post anymore, because when I do I have to type a bunch of the code out all over again ;).

james438
09-04-2008, 08:18 AM
Looks like the above is using ascii which I know even less about. The above post was mostly for fun. I was mostly playing around to see if I could get octal code to execute within a post. I remembered someone doing it once before, but it looks like they were posting ascii.

Twey
09-05-2008, 08:29 AM
'Octal code'... octal isn't code. It's just a way of encoding numbers. In this particular case, you're just using plain old decimal. In HTML, you could also have expressed those numbers as hexadecimal if you so desired (by following the '#' with an 'x').

james438
09-05-2008, 03:15 PM
my mistake. Thanks for the correction in my syntax. Would I call it octal encoded notation?

Using the decimal notation (as opposed to octal notation) in Opera I discovered that there is a symbol potentially listed anywhere from 0 to 65535. After that I didn't see anything. Encoded were many different symbols, but mostly letters or characters from many different languages. I know I am talking about 2 different notation types. I am mostly just rambling on a bit as I note my latest discovery of numerical representation of characters.

Twey
09-06-2008, 08:55 AM
It's simply a notation, yes — a way of writing numbers. Some numbers mean things that are most easily visible in octal notation.