Strange characters in writing ascii code on Mac (C++ and Armadillo linear algebra library)

StackOverflow https://stackoverflow.com/questions/21790528

  •  11-10-2022
  •  | 
  •  

Question

I am a Mac user. I implemented a program using the Armadillo linear algebra library. Using:

T.save("T.txt", raw_ascii); // this is a library function to save matrix into txt file

I was able to print the matrix T in T.txt file. It was successful on my Mac. The T.txt file eventually is loaded on MATLAB for the post-processing.

However, I copied the source codes to my friend's Mac and compiled. The txt file contains weird characters like:

 ˇˇ9.298452339097e-02 ˇ-1.343127536975e+00 ˇˇ3.188132564527e+01
 ˇˇ1.343127788111e+00 ˇˇ9.298420146411e-02 ˇ-1.630093163671e+01

and MATLAB fails to read the txt file.

Why does this happen? These computers are both Macs (maybe different models). Is it because of the different compilers? I did this using Xcode. Is there a way to specify some desired ASCII character set?

** ASIDE update: Thanks for all who replied. I checked the diskio::save_raw_ascii() inside the library. It uses

diskio::save_raw_ascii(...blah blah..., std::ostream& f)
f.put(' ');

I guess it does not have any problems, right? I think I need to test with this simple code on my friend's computer.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top