Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "base ten ASCII" mean?

Tags:

ascii

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?

like image 340
Breedly Avatar asked Jan 10 '23 14:01

Breedly


2 Answers

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 commonly written and makes a Bencoded file more accessible. (That said, Bencoded files are generally not "human editted".)

like image 71
user2864740 Avatar answered Mar 12 '23 13:03

user2864740


"Base 10 ASCII," as used in this context, is not one thing. It just means that a base 10 number is represented using ASCII characters.

like image 22
McLovin Avatar answered Mar 12 '23 14:03

McLovin