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

  • Home
  • SEARCH
  • 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 686667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:02:52+00:00 2026-05-14T02:02:52+00:00

Suppose I have this code: String encoding = UTF-16; String text = [Hello StackOverflow];

  • 0

Suppose I have this code:

String encoding = "UTF-16";
String text = "[Hello StackOverflow]";
byte[] message= text.getBytes(encoding);

If I display the byte array in message, the result is:

0000    FE FF 00 5B 00 48 00 65 00 6C 00 6C 00 6F 00 20     ...[.H.e.l.l.o.
0010    00 53 00 74 00 61 00 63 00 6B 00 4F 00 76 00 65     .S.t.a.c.k.O.v.e
0020    00 72 00 66 00 6C 00 6F 00 77 00 5D                 .r.f.l.o.w.]

As you can see, there’s a BOM in the beginning.

How can I:

  1. generate a UTF-16 byte array that lacks a BOM, from a string?
  2. convert from a byte array that contains UTF-16 chars but lacks a BOM, back to a string?
  • 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-14T02:02:52+00:00Added an answer on May 14, 2026 at 2:02 am

    You can explicitly choose a byte order by using “UTF-16BE” or “UTF-16LE” as the encoding. See the javadocs for Charset.

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

Sidebar

Related Questions

In javascript suppose you have this piece of code: <div> <script type=text/javascript>var output =
Let's suppose I have this piece of code. foreach(string value in myList) { string
Suppose I have this code: static void Main(string[] args) { var thread = new
Suppose I have some code like this: public string SomeMethod(int Parameter) { string TheString
Suppose I have this jQuery code. $(document).delegate('a[title]', 'click', function(event) { var txt = //
I have this code that suppose to place the marker by the latlng public
Suppose I have this (C++ or maybe C) code: vector<int> my_vector; for (int i
Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can
Suppose I have the code like this: <table> <tr> <th>name</td> <th>price</td> </tr> <tr> <td>a</td>
Suppose, I have a connected socket after writing this code.. if ((sd = accept(socket_d,

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.