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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:45:09+00:00 2026-05-24T21:45:09+00:00

I think that this is a newbie type question but I have quite understood

  • 0

I think that this is a newbie type question but I have quite understood this.

I can find many posts on how to convert a string to a byte array in various languages.

What I do not understand is what is happening at a character by character basis.
I understand that each character displayed on the screen is represented by a number such as it’s ascii code. (Can we stick with ASCII at the moment so I get this conceptually :-))

Does this mean that when I want to represent a character or a string (which is a list of chartacters) the following occurs

Convert character to ASCII value > represent ascii value as binary?

I have seen code that creates Byte arrays by defining the byte array as 1/2 the length of the input string so surely a byte array would be the same length of string?

So I am a little confused.
Basically I am trying to store a sting value into a byte array in ColdFusion which I cannot see has an explicit string to byte array function.

However I can get to the underlying java but I need to know whats happening at the theoretical level.

Thanks in advance and please tell me nicely if you think I am barking mad !!

Gus

  • 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-24T21:45:10+00:00Added an answer on May 24, 2026 at 9:45 pm

    In Java, strings are stored as an array of 16-bit char values. Each Unicode character in the string is stored as one or (rarely) two char values in the array.

    If you want to store some string data in a byte array, you will need to be able to convert the string’s Unicode characters into a sequence of bytes. This process is called encoding and there are several ways to do it, each with different rules and results. If two pieces of code want to share string data using byte arrays, they need to agree on which encoding is being used.

    For example, suppose we have a string s that we want to encode using the UTF-8 encoding. UTF-8 has the convenient property that if you use it to encode a string that contains only ASCII characters, every character in the input gets converted to a single byte with that character’s ASCII value. We might convert our Java string to a Java byte array as follows:

    byte[] bytes = s.getBytes("UTF-8");
    

    The byte array bytes now contains the string data from s, encoded into bytes using the UTF-8 encoding.

    Now, we store or transmit the bytes somewhere, and the code on the other end wants to decode the bytes back into a Java String. It will do something like the following:

    String t = new String(bytes, "UTF-8");
    

    Assuming nothing went wrong, the string t now contains the same string data as the original string s.

    Note that both pieces of code had to agree on what encoding was being used. If they disagreed, the resulting string might end up containing garbage, or might even fail to decode at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You might think that this question is already answered. However, I couldn't find the
I think that some newer languages like JS can do this natively, but I
Searching here I found that this question was already asked , but I think
This is a newbie type question. I want to create a public method that
Rails newbie, thanks for help with this hopefully basic JSON type question.... I have
I have a newbie question about jQuery. Why is it that I can trigger
This must be a very stupid newbie question, but I have spent my whole
I think that this problem can be sorted using reflection (a technology which I'm
I don't think that this could be done in C#, but posting this just
I don't think that this is doable, but wanted to throw it out to

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.