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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:47:30+00:00 2026-05-11T00:47:30+00:00

In C/C++, if a multi-byte wide character (wchar_t) value is transmitted from a big-endian

  • 0

In C/C++, if a multi-byte wide character (wchar_t) value is transmitted from a big-endian system to a little-endian system (or vice-versa), will it come out the same value on the other side? Or will the bytes need to be swapped?

  • 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. 2026-05-11T00:47:30+00:00Added an answer on May 11, 2026 at 12:47 am

    Yes you will need to swap them.
    The bytes will be retrieved from the transport in the same order they were put in. Just at the other end the ordering of these bytes has a different meaning. So you need to convert them to the correct endian-ness (is that a word?).

    The tried and true method is to convert to network byte order before transport. Then convert back to host specific byte order (from network byte order) on receipt.

    A set of function to help with endian conversion:

    ntohs   Convert a 16-bit quantity from network byte order to host byte order ntohl   Convert a 32-bit quantity from network byte order to host byte order htons   Convert a 16-bit quantity from host byte order to network byte order htonl   Convert a 32-bit quantity from host byte order to network byte order 

    Just to add another note of caution.
    Different systems use different size for wchar_t so do not assume sizeof(wchar_t) == 2.

    Additionally each host may use a different representational format for wchar_t.
    To help deal with this most systems convert the text to a known format for transport (UTF-8 or UTF-16 are good choices). The convert the text back to the host specific format at the other end.

    You could look at IBM’s icu this has all this functionality.

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

Sidebar

Related Questions

I've managed to mostly ignore all this multi-byte character stuff, but now I need
I have a multi-byte primitive type called s32 which I want to read from
printf(%s\n, multibytestring); By default the multi-byte characters will show up like ??? in console,
How do I convert text between multi-byte text strings, for example Simplified Chinese GB
I have a multi-byte string containing a mixture of japanese and latin characters. I'm
wcstombs documentation says, it converts the sequence of wide-character codes to multibyte string. But
Having a Unicode (multi-byte charset) Oracle database with NLS_LENGTH_SEMANTICS=BYTE seems like a disaster waiting
I was looking into multi-byte characters and how they are used but how many
IE has trouble with #&8302;(Actual character references) be interpreted as white space with multi
I've got a little problem with Zend Framework Zend_Pdf class. Multibyte characters are stripped

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.