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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:30:19+00:00 2026-05-26T08:30:19+00:00

I have some code from the net reading hyperspectral data (image, so lots of

  • 0

I have some code from the net reading hyperspectral data (image, so lots of integers giving pixel intensity) into a vector. I used the code with success on a Linux system, but now I need the same on a windows system. I use Visual Studio 2008.

Reading the data in Linux I get a vector full of integers. On windows I get the integers and then some chars or byte data. I don’t know enough to describe it better.

The vector is initialized by

std::vector< unsigned short int > data;
data.resize( samples * lines * bands );
std::fill( data.begin(), data.end(), 0 );

and the relevant code is

for( unsigned int i=0; i < num_pixels && file; ++i ){
     char number[sizeof(DataType)];
     file.read( number , sizeof( DataType ) );
     int l = sizeof(DataType)-1;
    if (machine_endian != header.big_endian) {
        for (int j = 0; j < l; j++, l--){
            number[j] ^=number[l];
            number[l] ^= number[j];
            number[j] ^= number[l];
        }
    }
 unsigned short temp = *((unsigned short int*)number);
     data[i] = temp;
}

The machine_endian part is never run. The temp is just to test if I can cast the number into an int. It works fine. However, when I put temp into the vector there’s more information inserted than just the int and it’s listed as wchar_t. See the image below. I guess it’s something to do with type size, but I am clueless as to why. Is it mine or Visual Studios fault? Any ideas?

  • 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-26T08:30:19+00:00Added an answer on May 26, 2026 at 8:30 am

    Actually, it is working fine. Microsoft just wants to facilitate inspecting wchar_t values (which are short ints and represent utf16 coded characters on windows), so their debugger shows short ints as wchar_ts. It’s just a matter of interpretation.

    If you had used chars for your data, you would encounter the same phenomenon on almost any architecture.

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

Sidebar

Related Questions

I have some existing code that retrieves data from a database using ADO.NET that
I have some code that downloads an image from a remote server $data =
Does anyone have some code that will take a TimeZoneInfo field from .NET and
I have some code which collects points (consed integers) from a loop which looks
I have inherited some code (from zip file) from a developer and git initialzed,
I have some code to read from a pdf file. Is there a way
I have ported some LGPL code from Java to C#, which I plan to
I have taken over some code from a previous developer and have come across
Imagine I have some code to read from the start to end of a
I have some code that will be accessed from two threads: class Timer{ public:

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.