Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMLHTTP & ISO-8859-1

Status
Not open for further replies.

CharlesFS

Technical User
Dec 14, 2008
39
BR
How can i set the right encoding into my post request function?
I tried : .setRequestHeader'encoding','ISO-8859-1'
But dont work

obs: the response xml have this header:
Code:
 <?xml version=""1.0"" encoding=""ISO-8859-1"" ?>

The function
Code:
Function HTTPSessionRequest(method, url, data)
Dim poStvars
Dim Xmlhttp
Dim Strheaders
Dim Sreturn
Dim Nlenhead
Dim Istart
Dim i, J
Dim Nfoundat
Dim Sref
'init
'Set Xmlhttp = CreateObject("MICROSOFT.XMLHTTP")
Set Xmlhttp = CreateObject("Msxml2.ServerXMLHTTP")
poStvars = Trim(data)
'connect
Xmlhttp.SetOption 2, 13056
Xmlhttp.Open method, Trim(url), False
With Xmlhttp
'set hdrs
If UCase(method) = "POST" Then
.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
End If
.setRequestHeader "User-Agent", _
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
'add the old referrer
.setRequestHeader "ACCEPT-LANGUAGE", "en-us"
.setRequestHeader "Accept", _
"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, " & _
"application/vnd.ms-excel, application/msword, */*"
'add a dummy cookie
.setRequestHeader "cookie", "dummy=dummy"
'send data
.Send poStvars
Strheaders = .getAllResponseHeaders()
Sreturn = .responseText
End With
'done with http
Set Xmlhttp = Nothing
HTTPSessionRequest = Sreturn
End Function

Call
Code:
s = HTTPSessionRequest("POST", PaginaDeConsulta, data1)

Thanks all
 
Have you tried this ?
.setRequestHeader "encoding", "ISO-8859-1"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV, thanks for the post but (.setRequestHeader "encoding", "ISO-8859-1" ) not work.

This worked:

Replace this line:
Code:
Sreturn = .responseText
For:
Code:
Sreturn = StrConv(conn.responseBody, vbUnicode)

thanks PHV
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top