2

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.

casperOne
  • 73,706
  • 19
  • 184
  • 253

8 Answers8

3

Try:

Session.CodePage = 28591

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

D'Arcy Rittich
  • 167,292
  • 40
  • 290
  • 283
3

Have you tried using Response.Charset and setting it like so:

<% Response.Charset="ISO-8859-1"%>
stealthyninja
  • 10,343
  • 11
  • 51
  • 59
2

Check the encoding of the .ASP file and all the .ASP files included with #include.

Once I had a problem when I created a new .ASP file in VS and was encoding in UTF-8. This file was included by others, and the file encoding "overwrites" all other encoding commands.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Eduardo Molteni
  • 38,786
  • 23
  • 141
  • 206
0

The solution:

Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
Response.CodePage = 65001
Response.CharSet = "UTF-8

Complete: https://pt.stackoverflow.com/questions/80886/encoding-asp-cl%C3%A1ssico/81418#81418

Community
  • 1
  • 1
Dorathoto
  • 201
  • 7
  • 17
0

AFAIK this is a known problem with WinHttpReq / XMLHTTPRequest, hope someone proves me wrong.

dr. evil
  • 26,944
  • 33
  • 131
  • 201
0

Have you tried using the meta tag equivalent to what you are doing?

Example:

Response.Write("<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1' />")

Note: I use a Response.Write to paste spit out the charset, because Visual Studio will attempt to save the file with a different encoding if, for example, the charset is UTF-8.

r0-
  • 2,388
  • 1
  • 24
  • 29
0

Reference this as well: How do I set the character set using XMLHttp Object for a POST in classic ASP?

Community
  • 1
  • 1
0

I have used this component both on ASP and Javascript, but on javascript I found the resolution for this issue here: http://squio.nl/blog/2006/06/27/xmlhttprequest-and-character-encoding/

Brian Webster
  • 30,033
  • 48
  • 152
  • 225