How to decode a (percent encoding URL) that contains Arabic characters?
If you want to do it manually, you'll have to write a function with UTF-8 support. However, there's an easier way which is to rely on the JScript engine using an MSScriptControl.ScriptControl
object. You could use the function from this answer.
Here's a complete example:
Public JSEngine
Public Sub InitializeJSEngine()
Set JSEngine = CreateObject("MSScriptControl.ScriptControl")
JSEngine.Language = "JScript"
End Sub
Function UrlDecode(s) As String
UrlDecode = Replace(s, "+", " ")
UrlDecode = JSEngine.CodeObject.decodeURIComponent(UrlDecode)
End Function
Private Sub Form_Load()
' Make sure this is called before calling `UrlDecode`.
InitializeJSEngine
End Sub
Private Sub btnDecode_Click()
' Prints: "دشمني در اعماق-2019-12-09 01:09:00"
' ..which is Persian, not Arabic ;‑)
Debug.Print UrlDecode("%D8%AF%D8%B4%D9%85%D9%86%DB%8C+%D8%AF%D8%B1+%D8%A7%D8%B9%D9%85%D8%A7%D9%82-2019-12-09+01%3A09%3A00")
End Sub