[bittorrent] BEncodedDictionary must have ordered keys... whatdefinition of "ordered"?

Brian Dessent brian at dessent.net
Wed Oct 25 16:12:22 EDT 2006


Alan McGovern wrote:

> Now, the problem is that the MS.NET framework defines that to be in
> non-alphabetical order as according to the String.Compare method in
> it, '-' should come after '.' So, which is right, .NET or BitComet?
> Also, there must be a standardised way of deciding which letters come
> before which that we can compare against. Anyone know where to find
> such a list?

This is not rocket science, and the fact that this would be confusing
really seems rather worrysome.  '-' is ascii 0x2d, '.' is ascii 0x2e,
therefore in a strictly binary-based comparison, - comes first.  And
that is what the spec defines, a strict lexicographical sort.

The reason .Net is sorting differently is it is not doing a binary sort,
it is doing a sort based on the setting of the current locale, which
defines a collation order that gives a natural sort order for that
culture/locale.  So either set the locale to C/Posix or use a binary
sort and not a natural sort.

Brian



More information about the BitTorrent mailing list