Reputation:
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.
Upvotes: 2
Views: 25866
Reputation:
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.
Upvotes: 0
Reputation: 236
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
Upvotes: 0
Reputation: 39413
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.
Upvotes: 2
Reputation:
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/
Upvotes: 0
Reputation:
Have you tried using Response.Charset and setting it like so:
<% Response.Charset="ISO-8859-1"%>
Upvotes: 3
Reputation:
Reference this as well: How do I set the character set using XMLHttp Object for a POST in classic ASP?
Upvotes: 0
Reputation: 27265
AFAIK this is a known problem with WinHttpReq / XMLHTTPRequest, hope someone proves me wrong.
Upvotes: 0
Reputation: 171351
Try:
Session.CodePage = 28591
There is some good information here, and I got the CodePage number here.
Upvotes: 3