Shawn
Shawn

Reputation: 353

Incorrect Encoding Between Classic ASP and Access

I have a user search that is written in classic-asp and hooks into an Access database. The client would like it to be accent-insensitive so searching for a name like LeLievre would return the entry LeLièvre.

Since there is no way to do this in access I wrote a quick function that modifies the search query to include all options for an accent, as seen here:

    strOutput = ""
    For i = 1 to Len(input)
        curLetter = Mid(input, i, 1)
        Select Case curLetter
            case "e", "é", "è", "ê", "ë", "E", "É", "È", "Ê", "Ë"
                strOutput = strOutput & "[eéèêëEÉÈÊË]"
            case "a", "à", "â", "ä", "A", "À", "Â", "Ä"
                strOutput = strOutput & "[aàâäAÀÂÄ]"
            Case "i", "ì", "ï", "î", "I", "Ì", "Ï", "Î"
                strOutput = strOutput & "[iïîìIÏÎÌ]"
            Case "o", "ô", "ö", "ò", "O", "Ô", "Ö", "Ò"
                strOutput = strOutput & "[oôöòOÔÖÒ]"
            Case "u", "ù", "û", "ü", "U", "Ù", "Û", "Ü"
                strOutput = strOutput & "[uûüùUÛÜÙ]"
            Case "c", "ç", "C", "Ç"
                strOutput = strOutput & "[cçCÇ]"
            Case Else           
                strOutput = strOutput & curLetter
        End Select
    Next

Now, to my problem. I have the page set to use "ISO-8859-1" as well as the asp CodePage/CharSet set (I've also tried UTF-8) but it looks like my page is using two different encodings.

What I mean is if I search for "LeLièvre" and then print out the query generated, it isn't finding the "è" and replacing it with "[eéèêëEÉÈÊË]". Also if I print out the query to the page everything is a mess and in the wrong encoding except the "è" that was not found and replaced. Here is a portion of the query,
AND LastName LIKE '%L[eéèêëEÉÈÊË]L[iïîìIÃÃŽÃŒ]èvr[eéèêëEÉÈÊË]%'

This incorrectly encoded query being generated is then resulting in nothing being found in the database.

Unfortunately I don't have much experience dealing with encodings and after fiddling with this for the last while and being completely stumped I've had to come here for some help.

Any advice would be greatly appreciated.

Upvotes: 0

Views: 1034

Answers (1)

AardVark71
AardVark71

Reputation: 4116

try saving your classic asp with UTF-8 encoding.

I don't know which editor you use but most editors (Notepad++, Textpad, ...) can specify additionally with which encoding the asp page it selves should be saved.

Upvotes: 2

Related Questions