AP_DECLARE(int) ap_cstr_casecmpn(const char *s1, const char *s2, apr_size_t n)
{
    const unsigned char *str1 = (const unsigned char *)s1;
    const unsigned char *str2 = (const unsigned char *)s2;
    while (n--)
    {
        const int c1 = (int)(*str1);
        const int c2 = (int)(*str2);
        const int cmp = ucharmap[c1] - ucharmap[c2];
        /* Not necessary to test for !c2, this is caught by cmp */
        if (cmp || !c1)
            return cmp;
        str1++;
        str2++;
    }
    return 0;
}