UTF-8 text conversion function for legacy systems

In ASP, a simple converter that I made in my service to convert UTF-8 code for the most used characters (as in a text) to correct characters. This is very useful when we have sites entirely in UTF-8 and only some component cannot read the characters. This code can probably be migrated to another language:

function UTF8_ANSI(x)
    ' Check if do you are using the codepage 1252 or this script doesn't works properly.
    ' Verifique se você está usando o código de página 1252 ou este não funcionará corretamente.
    ' <.%@LANGUAGE="VBSCRIPT" CODEP A G E = "1252" %.>
    Cod = second(now()) + minute(now())
    for ife = 1 to 191 : x=replace(x,chr(195)&chr(ife),chr(ife+64)) : next
end function

This will make it possible to encode the characters correctly.

No comments