[Xesam] Sortkeys: read this

Philip Van Hoof spam at pvanhoof.be
Tue Sep 23 08:43:00 PDT 2008


On Tue, 2008-09-23 at 17:32 +0200, Philip Van Hoof wrote:
> http://www.ietf.org/rfc/rfc4790.txt


An example from this document:


9.3.  Octet Collation

9.3.1.  Octet Collation Description

   The "i;octet" collation is a simple and fast collation intended for
   use on binary octet strings rather than on character data.  Protocols
   that want to make this collation available have to do so by
   explicitly allowing it.  If not explicitly allowed, it MUST NOT be
   used.  It never returns an "undefined" result.  It provides equality,
   substring, and ordering operations.

   The ordering algorithm is as follows:

   1.  If both strings are the empty string, return the result "equal".

   2.  If the first string is empty and the second is not, return the
       result "less".

   3.  If the second string is empty and the first is not, return the
       result "greater".

   4.  If both strings begin with the same octet value, remove the first
       octet from both strings and repeat this algorithm from step 1.

   5.  If the unsigned value (0 to 255) of the first octet of the first
       string is less than the unsigned value of the first octet of the
       second string, then return "less".

   6.  If this step is reached, return "greater".

   This algorithm is roughly equivalent to the C library function
   memcmp, with appropriate length checks added.



-- 
Philip Van Hoof, freelance software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://pvanhoof.be/blog
http://codeminded.be



More information about the Xesam mailing list