VB6 URL Decoding – Decoding Special Characters in URL/Web Address from Other Languages -.NET

This page is going to show you how to take a url, in html code, and take cryptic looking characters that you would find in other languages and turn them into the characters they are suppose to be for that country.

For example, when performing a search in German (https://www.google.de/) for the phrase Hundetraining (Dog Training) one of the urls on the page under Related Searches, one of the related search words/phrases is hundetraining übungen, but the url in the html code is  /search?q=hundetraining+%C3%BCbungen&sa=X&ved=0ahUKEwit58bQudvWAhUm04MKHdGHBDUQ1QIIpQEoAw

This presents a problem if you are trying to scrape the related searches because you can see the url takes the letter ü and turns it into %C3%BC.

You would think a simple URLdecode function or sub routine would take care of this but it does not. There are some very complicated and lengthy code solutions for this but here is one that only takes a few lines of code.

At the top of the code module …

(the following code assumes it is being placed in a class, if a form instead then just change Class_Initialize to Form_Load and Class_Terminate to Form_Unload or Form_QueryUnload)

The function that decodes the weird looking characters in a url for just about any language …

NOTE: if you would prefer not to reference JSEngine As Object you can set a reference to the Microsoft Script Control (Project > References)

url-decode-foreign-language-project-references

url-decode-foreign-language-project-references

url-decode-foreign-language-microsoft-script-control

url-decode-foreign-language-microsoft-script-control