HTTPRequest UTF-8

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
macroman
Pro Scripter
Posts: 91
Joined: Mon Jun 02, 2014 5:32 am

HTTPRequest UTF-8

Post by macroman » Tue Oct 11, 2016 6:00 pm

I can grab results in utf-8 just fine, but when POST/GET with utf-8 characters, i'm getting errors

Code: Select all

Let>HTTP_CHARSET=UTF-8
Let>PostData=test=Nhạc Sàn Cực Mạnh 2016 - Chất Gây Mê Dành Cho Đám Cưới Phê Tới Sáng
HTTPRequest>http://www.domain.com/vinsert.php,,POST,PostData,doneadd,,,,

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: HTTPRequest UTF-8

Post by Marcus Tettmar » Wed Oct 12, 2016 7:50 am

It might need URL encoding:

Code: Select all

VBSTART
Dim JSEngine
Set JSEngine = CreateObject("MSScriptControl.ScriptControl")
    JSEngine.Language = "JScript"
Function UrlEncode(s)
    UrlEncode = JSEngine.CodeObject.encodeURIComponent(s)
    UrlEncode = Replace(UrlEncode, "'", "%27")
    UrlEncode = Replace(UrlEncode, """", "%22")
End Function
Function UrlDecode(s)
    UrlDecode = Replace(s, "+", " ")
    UrlDecode = JSEngine.CodeObject.decodeURIComponent(UrlDecode)
End Function
VBEND

Let>PostData=test=Nhạc Sàn Cực Mạnh 2016 - Chất Gây Mê Dành Cho Đám Cưới Phê Tới Sáng
VBEval>URLEncode("%PostData%"),encPostData
HTTPRequest>http://www.domain.com/vinsert.php,,POST,encPostData,doneadd,,,,
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts