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

Alan McGovern alan.mcgovern at gmail.com
Wed Oct 25 16:33:36 EDT 2006


Thats exactly what i was trying to find out. The spec definately didn't
clearly spell out what kind of sort was being used. I assumed that a normal
string.compare() would be sufficient. Obviously not, as it takes culture
into account.

I'll update the spec on wiki.theory.org to make sure that point is clearly
made. I've now switched to a string.CompareOrdinal() which does a binary
comparison and everythings ok.


On 10/25/06, Brian Dessent <brian at dessent.net> wrote:
> 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
> _______________________________________________
> BitTorrent mailing list
> BitTorrent at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/bittorrent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ibiblio.org/pipermail/bittorrent/attachments/20061025/ddb90888/attachment.html 

More information about the BitTorrent mailing list