Jump to content

$oHTTP.Send($sData) always send $sData as UTF-8?


Luigi
 Share

Recommended Posts

Hi forum!

In this generic example, I thinking the $sData always out/go to server as UTF-8... This is correct?

#include-once
#include <Array.au3>

Global Const $HTTP_STATUS_OK = 200
Global $sURL = "http://localhost/receive.php"
Global $sData = '"anyword"'

Global $TRY = HttpPost($sURL, "save", $sData)

Func HttpPost($sURL, $cmd, $sData = "")
    Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
    $oHTTP.Open("POST", $sURL & "?cmd=" & $cmd, False)
    If (@error) Then Return SetError(1, 0, 0)

    $oHTTP.SetRequestHeader("Content-Type", "application/json; charset=UTF-8")

    $oHTTP.Send($sData)
    $oHTTP.WaitForResponse()
    If (@error) Then Return SetError(2, 0, 0)

    If ($oHTTP.Status <> $HTTP_STATUS_OK) Then Return SetError(3, 0, 0)

    Return SetError(0, 0, $oHTTP.ResponseText)
EndFunc   ;==>HttpPost

I ask this, becouse I use this little pseudo-code in PHP:

echo "\$HTTP_RAW_POST_DATA[ {$HTTP_RAW_POST_DATA} ]\n";
echo "mb_detect_encoding[ " . mb_detect_encoding($HTTP_RAW_POST_DATA, "auto") . " ]\n";

And always return UTF-8...

The reason for this post is the difficulty in transporting special characters from AutoIt to PHP, and at this time of my study, I am standing here.

I thought that the $sData's output was coding the string in case the Unicode (native AutoIt). That is right?

 

Thanks,

Detefon.

Visit my repository

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...