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 7959587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:35:49+00:00 2026-06-04T04:35:49+00:00

I have a specific requirement to convert a stream of bytes into a character

  • 0

I have a specific requirement to convert a stream of bytes into a character encoding that happens to be 6-bits per character.

Here's an example:

Input: 0x50 0x11 0xa0

Character Table:

010100 T
000001 A
000110 F
100000 SPACE


Output: "TAF "

Logically I can understand how this works:

Taking 0x50 0x11 0xa0 and showing as binary:

01010000 00010001 10100000

Which is "TAF ".

What’s the best way to do this programmatically (pseudo code or c++). Thank you!

  • 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-06-04T04:35:50+00:00Added an answer on June 4, 2026 at 4:35 am

    Well, every 3 bytes, you end up with four characters. So for one thing, you need to work out what to do if the input isn’t a multiple of three bytes. (Does it have padding of some kind, like base64?)

    Then I’d probably take each 3 bytes in turn. In C#, which is close enough to pseudo-code for C 🙂

    for (int i = 0; i < array.Length; i += 3)
    {
        // Top 6 bits of byte i
        int value1 = array[i] >> 2;
        // Bottom 2 bits of byte i, top 4 bits of byte i+1
        int value2 = ((array[i] & 0x3) << 4) | (array[i + 1] >> 4);
        // Bottom 4 bits of byte i+1, top 2 bits of byte i+2
        int value3 = ((array[i + 1] & 0xf) << 2) | (array[i + 2] >> 6);
        // Bottom 6 bits of byte i+2
        int value4 = array[i + 2] & 0x3f;
    
        // Now use value1...value4, e.g. putting them into a char array.
        // You'll need to decode from the 6-bit number (0-63) to the character.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my requirement. I have a client that was sending a specific message
I have a specific requirement that all children of a particular JComponent have double
We have a requirement that a user can load any standard image into a
We have a posting analyzing requirement, that is, for a specific post, we need
I have a specific question, that could use a general answer... When building Multi-Tier
I have a specific Silverlight application, that is fed with data by a WCF-Service.
I have a requirement to focus on a specific textbox when a new view
I have a requirement to run a query against a database that will return
I recently moved to a project where I noticed there have a specific requirement
I have a specific requirement to have autocomplete in an Oracle BPM project. I

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.