Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 861827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:02:30+00:00 2026-05-15T09:02:30+00:00

I have a byte array that I’m encoding to a string: Private Function GetKey()

  • 0

I have a byte array that I’m encoding to a string:

Private Function GetKey() As String
    Dim ba() As Byte = {&H47, &H43, &H44, &H53, &H79, &H73, &H74, &H65, &H6D, _
                        &H73, &H89, &HA, &H1, &H32, &H31, &H36}

    Dim strReturn As String = Encoding.ASCII.GetString(ba)

    Return strReturn
End Function

Then I write that to a file via IO.File.AppendAllText.
If I open that file in 010 Editor (to view the binary data) it displays as this:

47 43 44 53 79 73 74 65 6D 73 3F 0A 01 32 31 36

The original byte array contained 89 at position 11, and the encoded string contains 3F.
If I change my encoding to Encoding.Default.GetString, it gives me:

47 43 44 53 79 73 74 65 6D 73 E2 80 B0 0A 01 32 31 36

Any help would be much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:02:31+00:00Added an answer on May 15, 2026 at 9:02 am

    Encoding.ASCII is limited to 7-bit characters. That is byte values from 0 to 127 (&H00 to &H7F). GetString sets all values outside this range to &H3F which is a questionmark.

    Encoding.Default is the current ANSI code page for the operating system which on my computer is CodePage 1252..

    The ANSI code pages can be different
    on different computers, or can be
    changed for a single computer, leading
    to data corruption. For the most
    consistent results, applications
    should use Unicode, such as UTF-8
    (code page 65001) or UTF-16, instead
    of a specific code page.

    Encoding.UTF7 would work for you here:

    Dim strReturn As String = Encoding.UTF7.GetString(ba)
    

    Edit:

    Instead of using Encoding I’d write the bytes directly using something like this:

    Dim key = GetKey()
    Dim f = System.IO.File.OpenWrite("output.txt")
    f.Seek(0, SeekOrigin.End)
    f.Write(key, 0, key.Length)
    f.Close()
    
    Private Function GetKey() As String
      Dim ba() As Byte = {&H47, &H43, &H44, &H53, &H79, &H73, &H74, &H65, &H6D, &H73, &H89, &HA, &H1, &H32, &H31, &H36}
    
      Return ba
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a byte array that contains list of unicode strings. Each string is
I have to process a large byte array that is passed to my function.
I have a byte array that may or may not have null bytes at
I have an SHA-1 byte array that I would like to use in a
I have a control that has a byte array in it. Every now and
I have an API call that returns a byte array. I currently stream the
I have a service that converts images stored on a website to byte array
I have a byte that is an array of 30 bytes, but when I
I have a an array of byte, size n, that really represents an array
I have a byte array that's been initialized with 0xFF in each byte: for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.