Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Http responseText
Message
From
07/05/2022 06:39:34
 
 
To
06/05/2022 07:57:54
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
01684339
Message ID:
01684345
Views:
52
Carlos, it's a bit tricky in VFP6.

First, you probably should use .responseBody instead, because there is no transformation of what is sent by the server (beware, it's a byte array so you need to address it as an array, not as a string).

Then, you need to convert the UTF-8 to ISO-Latin-1. Since you don't have anything native in VFP6 for that, you must build your own conversion. If you're only needing to take care of the basic Latin UNICODE block (that's what is required for Portuguese), then this will do:
oHTTP = CREATEOBJECT("WinHttp.WinHttpRequest.5.1")
WITH oHTTP
.Open("GET", m.lcURL, .f.)
ENDWITH
oHTTP.send()
m.the_name_array = oHTTP.responseBody
m.the_name = ""
m.ind = 1
do while m.ind < alen(m.the_name_array)
	m.ch = m.the_name_array[m.ind]
	do case
	case chr(m.ch) == 'Â'
		m.ind = m.ind + 1
		m.ch = m.the_name_array[m.ind]
	case chr(m.ch) == 'Ã'
		m.ind = m.ind + 1
		m.ch = m.the_name_array[m.ind] + 64
	endcase
	the_name = the_name + chr(m.ch)
	m.ind = m.ind + 1
enddo
? m.the_name
>Good Morning,
>In VFP6,
>I'm trying to get the name 'CORNÉLIO' with the following code, but it's returning 'CORNÃ?LIO'.
>what parameter should I pass to http to not convert the value
>Can someone explain to me how to do it.
>thank you in advance
>
>oHTTP = CREATEOBJECT("WinHttp.WinHttpRequest.5.1")
>WITH oHTTP
>.Open("GET", lcURL, lcAsyncMode)
>.setRequestHeader('Accept', 'application/json')
>ENDWITH
>oHTTP.send()
>the_name = oHTTP.responseText
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform