Breedly
Breedly

Reputation: 14226

What does "base ten ASCII" mean?

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?

Upvotes: 4

Views: 5237

Answers (5)

user2864740
user2864740

Reputation: 61885

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".)

Upvotes: 7

exussum
exussum

Reputation: 18560

integer encoded in base ten ASCII

that means numbers like you count with eg 1, 9, 11, 123. ASCII is http://en.wikipedia.org/wiki/ASCII#ASCII_control_code_chart

Your looking in the Dec Column

encoded in base 10 means the number, and ASCII meaning the letter representation of the numbers, for easier reading in a text editor

Upvotes: 0

sjcaged
sjcaged

Reputation: 649

Base 10 ASCII means, you write out the ASCII code of the character in base 10, instead of base 16.

A would thus be written as 65. The space character would be written as 32. m would be written as 109.

This contrasts with (for example) URL-encoded ASCII, which is base 16. In URL encoding, %41 is A, %20 is space, and %6D is m.

Upvotes: 0

jefflunt
jefflunt

Reputation: 33954

As opposed to binary? Looks like the number 5 is shown in its base-10 form 5 instead of the binary version 101.

Upvotes: 1

McLovin
McLovin

Reputation: 3674

"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.

Upvotes: 1

Related Questions