0

I have access to a database with a phone number, I want to send an Arabic sms to the phone number, I use this code to send:

Dim result As String
Dim myUrl As String

Dim winHttpReq As Object
Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
myUrl = "http://www.nsms.ps/api.php?comm=sendsms&user=user&pass=pass&to=number&message=مرحبا&sender=TrueMark"
    winHttpReq.Open "GET", myUrl, False
    winHttpReq.Send

    result = winHttpReq.responseText

My code is working and I receive an sms to my phone, but I did not receive it in Arabic word order. I receive it like this: ط§ظ„ط³ظ„ط§ظ… ط¹ظ„ظٹظƒظ…

1 Answers1

0

URLs generally need to be UTF-8 encoded or percent-encoded.

These are pretty broad subjects, but luckily, this answer contains a percent-encoder that supports unicode. Use it to percent-encode the Arabic characters in your URL. It just needs to be adjusted for 64-bit operations if you want to use it on 64-bit Access.

If you want to go the UTF-8 way, you'll need to replace the COM WinHTTPRequest object with WinHTTP Flat API calls, and call WideCharToMultiByte to convert the string from UTF-16 to UTF-8. That's not a trivial task, unfortunately.

Erik A
  • 31,639
  • 12
  • 42
  • 67