[bittorrent] Bittorrent peer_id ASCII and Unicode?

Thad Ward coderjoe at grnet.com
Mon Mar 13 13:24:20 EST 2006

On Mon, Mar 13, 2006 at 07:00:40PM +0100, Olaf van der Spek wrote:
> On 3/13/06, Thad Ward <coderjoe at grnet.com> wrote:
> > > I think the common assumption is that it's restricted to bytes (0 - 0xff).
> >
> > I wouldn't say that is much of a restriction, as everything in a
> > computer is stored as bytes, including unicode characters. :P
> Only if the other requirement is that of a 20 byte value. If it's a 20
> character value then the 0 - 0xff restriction is a real restriction.

True. And unfortunately, the spec just says "Strings are length-prefixed
base ten followed by a colon and the string." There is no mention if
this is the byte length or the character length. There is also no
mention of a character encoding, which would mean we should treat that
as a byte length, and, when displaying the string, only know for sure
what the meanings of 0-127 are, as they are the only _standard_ set of
characters (well, as long as you use ASCII. I don't think many people
use EBCDIC, though.) "Strings" that are not really intended to be
displayed as is, such as the piece hash string, don't have the problem
of character encoding, though.

Note that I am referring to the official spec here, not the wiki spec.
The wiki spec appears to be a little clearer, as it calls them "byte

More information about the BitTorrent mailing list