IMAP sort requires input string collation according to the i;unicode-casemap, 
which describes string conversion to "titlecased
   canonicalized UTF-8".
Conversion consists of sequential conversion of string's unicode codepoints to 
"titlecase property" (which is normally the same as the
              uppercase property according to RFC).
This conversion shouldn't be locale-dependant, so I came up with this fix 
(works with PostgreSQL, hasn't been tested with other dbs):

    else if ( MATCH(key, "subject") ) {
        _append_join(value->table, "subjectfield");
        _append_sort(value->order, "UPPER(COALESCE(sortfield, '')) 
COLLATE\"C\"", reverse);
        (*idx)++;
    }

COLLATE "C" is necessary because of locale issues (database could be created 
with different locales, and PostgreSQL's sorting depends on the initial locale).

It works fine except that null strings won't sort correctly in reversed order 
(they mess with empty strings).
_______________________________________________
Dbmail-dev mailing list
Dbmail-dev@dbmail.org
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail-dev

Reply via email to