lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LYNX-DEV 8bit case-insensitive search on DOS/WIN...


From: Leonid Pauzner
Subject: LYNX-DEV 8bit case-insensitive search on DOS/WIN...
Date: Fri, 27 Feb 1998 04:00:20 +0300 (MSK)

Mapping for 8bit upper/lower case letters unique for every certain charset.
Currently Lynx use that information from UNIX locale
which usually fails for any dos/win display charset.

Another method will be introduced in #116,
it based on this function:




#ifdef EXP_8BIT_TOUPPER

/*
**   UPPER8 ?
**   it was "TOUPPER(a) - TOUPPER(b)" in its previous life...
**
**   It was realized that case-insensitive user search
**   got an information about upper/lower mapping from TOUPPER
**   (precisely from "TOUPPER(a) - TOUPPER(b)").
**   This function depends on locale in its 8bit mapping
**   and usually fails on non-UNIX systems.
**
**   We extend this function for 8bit letters
**   using Lynx internal chartrans feature:
**   we assume that upper/lower case letters
**   have their "7bit approximation" images (in def7_uni.tbl)
**   matched case-insensitive (7bit).  - LP
**
*/
PUBLIC int UPPER8(int ch1, int ch2)
{
    /* Use exact match for speed, but mostly for stability          */
    /* while doing experiments with the rest part of this function. */
    if (ch1==ch2)
        return(0);  /* Exact match */

    /* case-insensitive match for us-ascii */
    if ((unsigned char)ch1 < 128 && (unsigned char)ch2 < 128)
        return(TOUPPER(ch1) - TOUPPER(ch2));

    /* compare "7bit approximation" for letters >127   */
    if ((unsigned char)ch1 > 127 && (unsigned char)ch2 >127)

    {
    /* BTW, if we remove the check for >127 above      */
    /* we got even more "relaxed" insensitive match... */

        CONST char *disp_charset;
        int charset_in, charset_out, uck1, uck2;
        char replace_buf1 [10], replace_buf2 [10];

        disp_charset = LYCharSet_UC[current_char_set].MIMEname;
        charset_in  = UCGetLYhndl_byMIME(disp_charset);
        charset_out = UCGetLYhndl_byMIME("us-ascii");

        uck1 = UCTransCharStr(replace_buf1, sizeof(replace_buf1), ch1,
                              charset_in, charset_out, YES);
        uck2 = UCTransCharStr(replace_buf2, sizeof(replace_buf2), ch2,
                              charset_in, charset_out, YES);

        if ((uck1 > 0) && (uck2 > 0))
        /*
        ** Got both replacement strings (yippey).  - FM
        */
        return (strcasecomp(replace_buf1, replace_buf2));

    }

    return(-10);  /* mismatch */
}

#endif /* EXP_8BIT_TOUPPER */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]