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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:53:15+00:00 2026-05-14T16:53:15+00:00

How can I encode strings on UTF-16BE format in PHP? For Demo Message!!! the

  • 0

How can I encode strings on UTF-16BE format in PHP? For “Demo Message!!!” the encoded string should be ‘00440065006D006F0020004D00650073007300610067006’. Also, I need to encode Arabic characters to this 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-05-14T16:53:16+00:00Added an answer on May 14, 2026 at 4:53 pm

    First of all, this is absolutly not UTF-8, which is just a charset (i.e. a way to store strings in memory / display them).

    WHat you have here looks like a dump of the bytes that are used to build each characters.

    If so, you could get those bytes this way :

    $str = utf8_encode("Demo Message!!!");
    
    for ($i=0 ; $i<strlen($str) ; $i++) {
        $byte = $str[$i];
        $char = ord($byte);
        printf('%02x ', $char);
    }
    

    And you’d get the following output :

    44 65 6d 6f 20 4d 65 73 73 61 67 65 21 21 21 
    

    But, once again, this is not UTF-8 : in UTF-8, like you can see in the example I’ve give, `D` is stored on only one byte : `0x44`

    In what you posted, it’s stored using two Bytes : 0x00 0x44.

    Maybe you’re using some kind of UTF-16 ?


    EDIT after a bit more testing and @aSeptik’s comment : this is indeed UTF-16.

    To get the kind of dump you’re getting, you’ll have to make sure your string is encoded in UTF-16, which could be done this way, using, for example, the mb_convert_encoding function :

    $str = mb_convert_encoding("Demo Message!!!", 'UTF-16', 'UTF-8');
    

    Then, it’s just a matter of iterating over the bytes that make this string, and dumping their values, like I did before :

    for ($i=0 ; $i<strlen($str) ; $i++) {
        $byte = $str[$i];
        $char = ord($byte);
        printf('%02x ', $char);
    }
    

    And you’ll get the following output :

    00 44 00 65 00 6d 00 6f 00 20 00 4d 00 65 00 73 00 73 00 61 00 67 00 65 00 21 00 21 00 21 
    

    Which kind of looks like what youy posted 🙂

    (you just have to remove the space in the call to printf — I let it there to get an easier to read output=)

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

Sidebar

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This isn't the answer you're looking for, but hopefully will… May 16, 2026 at 4:06 pm
  • Editorial Team
    Editorial Team added an answer Dunno if you're still unsure about how to embed binary… May 16, 2026 at 4:06 pm
  • Editorial Team
    Editorial Team added an answer I use DB sessions all the time with Zend and… May 16, 2026 at 4:06 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Can php convert strings with all charset encodes to utf8? Solutions that don't works:
I am trying to base64 encode a string in PHP and openssl. openssl: echo
I constantly get this error using mako: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0'
Lately, I've had lots of trouble with __repr__() , format() , and encodings. Should
I'm having problems using {% ifequal s1 some text %} to compare strings with
I have ascii strings which contain the character \x80 to represent the euro symbol:
I'm trying to parse UTF-8 XML file and save some parts of it to
I'm having a problem where PHP (5.2) cannot find the character 'Â' in a
I am trying to figure out PyObjC on Mac OS X, and I have
I have to store hindi text in a MySQL database, fetch it using a

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.