How to Convert to a UTF-8 Using Visual Basic

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Convert to a UTF-8 Using Visual Basic
Use Visual Basic to encode in UTF-8. (code image by Charles Taylor from Fotolia.com)

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:
Moderate

Other People Are Reading

Instructions

  1. 1

    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

  2. 2

    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.

  3. 3

    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)

  4. 4

    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:

    MsgBox arrBytes.ToString()

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.