The UTF-8 language provides an encoding standard used on the internet for online URLs and e-mail communication. UTF-8 is used in Visual Basic coding for online communications, including links, URL submissions and sending e-mail to users. The Visual Basic language has an internal function that automatically encodes a string to UTF-8 standards. The results from the function return a byte array you can use to code your application.
- Skill level:
Other People Are Reading
Create a byte array. This variable is defined and later used to hold the results of your UTF-8 conversion. The following code creates an array in Visual Basic:
Dim arrBytes() As Byte
Create a string that contains a URL. The following code shows you how to create a string for a URL:
Dim url As String url = "your_domain.com"
Replace "your_domain.com" with the URL you want to encode.
Encode the string and store it in the byte array you created. The following code encodes the URL to UTF-8 standards:
arrByte = Encoding.UTF8.GetBytes(url)
Print out the results. These results are shown to the user or you can print out results for testing purposes. The following code creates a message box with the results:
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for