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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:25:18+00:00 2026-06-10T16:25:18+00:00

How can I convert an array of bytes into a UTF-8 string? I need

  • 0

How can I convert an array of bytes into a UTF-8 string? I need this because I am extracting from a binary format.

  • 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-10T16:25:19+00:00Added an answer on June 10, 2026 at 4:25 pm

    A string is nothing more than an array of bytes. So a UTF-8 string is the very same as an array of bytes, except that in addition you know what the array of bytes represent.

    So your input array of bytes needs one more additional information as well: the character set (character encoding). If you know the input character set, you can convert the array of bytes to another array of bytes representing an UTF-8 string.

    The PHP method for doing that is called mb_convert_encoding().

    PHP itself does not know of character sets (character encodings). So a string really is nothing more than an array of bytes. The application has to know how to handle that.

    So if you have an array of bytes and want to turn that into a PHP string in order to convert the character set using mb_convert_encoding(), try the following:

    $input = array(0x53, 0x68, 0x69);
    $output = '';
    for ($i = 0, $j = count($input); $i < $j; ++$i) {
        $output .= chr($input[$i]);
    }
    $output_utf8 = mb_convert_encoding($output, 'utf-8', 'enter input encoding here');
    

    (Instead of the single example above, have a look at more examples at https://stackoverflow.com/a/5473057/530502.)

    $output_utf8 then will be a PHP string of the input array of bytes converted to UTF-8.

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

Sidebar

Related Questions

I wanted to convert string into array of bytes . How can i do
I have a function that can decode an array of bytes into a string
I just wrote this code to convert a GUID into a byte array. Can
How can I convert a PSID type into a byte array that contains the
How can I convert a Class to byte array in C#. This is a
How can i convert this JSON array: This is a serialized JSON array 2012-06-18
What is the right way to convert raw array of bytes into Image in
What is the best way to convert a char array (containing bytes from a
I need to convert a PNG Image loaded from a file into an 8
I am trying to convert an array of bytes into a ZIP file. 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.