Encoding problem classic ASP

asp-classiccharacter encodingencoding

I have a problem with classic ASP. The encoding is wrong when I send data with XMLHttp.send. The response is a PDF file, but the “ÆØÅ” gets wrong, the “Ø” is read as “øy” for example. It’s like it’s a converting mistake from UTF-8 to ISO-8859-1, but it should be ISO-8859-1 now. I have <%@CODEPAGE="28591"%> at the top at the page and ISO-8859-1 as encoding in the XML file, I have checked the file so it’s valid ISO-8859-1. I don’t have access to the server I am sending this data to, but I fixed it in a VB6 program which use the same logic with:

aPostBody = StrConv(strBody, vbFromUnicode)
WinHttpReq.SetTimeouts 100000, 100000, 100000, 1000000
WinHttpReq.Send aPostBody

And in a C# program that also uses the same logic with

// ISO-8859-1
byte[] bytes = Encoding.GetEncoding(28591).GetBytes(data);

But in ASP classic I need some help to find a way to change the encoding on a string to ISO-8859-1.

Best Answer

Try:

Session.CodePage = 28591

There is some good information here, and I got the CodePage number here.