Maybe I'm doing a terrible job of using the Google, but these specifications for Bencoding keep referring to something known as "base ten ASCII", which makes me think it's different than regular ASCII. Could someone explain?
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Answer;
The base is explicitly stated to avoid confusion (although one might argue that base-10 is generally assumed by default).
Consider this: given the text representation of "12" (in ASCII), what is the numeric value?
- If it is base-10, that would be 1 * 10 + 2 -> 12.
- If it was base-8 (oct), it would be 1 * 8 + 2 -> 10.
- If it was in base-16 (hex), it would be 1 * 16 + 2 -> 18.
However, in Bencode it's always base 10, so 42 (the integer) is encoded as "i42e".
A use of base-16 over base-10 might be to save a byte in longer ASCII-encoded numbers or to ensure a consistent pad size .. but base-10 fits in better with how numbers are traditionally dealt with and makes a Bencoded file more accessible.
No comments:
Post a Comment