Strange symbol in file name - outputting file from Xcode and loading into Matlab

조회 수: 1 (최근 30일)
Hi all, I am trying to output a text file in C++ (using xcode on a Mac), and then upload the same data into Matlab.
However, the text file I output from xcode (which should be called '/Users/robinthompson/Documents/JTBWhenIsEpidemicOverPaper/⁨MCMCResults_18351555Time_212.txt') only loads into Matlab from the command window if I write
load('/Users/robinthompson/Documents/JTBWhenIsEpidemicOverPaper/⁨?MCMCResults_18351555Time_212.txt')
, where the question mark before the file name is instead a weird rectangle symbol...
Furthermore, because the weird rectangle symbol is not a standard character, the same command doesn't work to upload the file when I run the load command from a Matlab script...
This is driving me crazy - is there a solution? What is this strange rectangle? Thanks in advance!
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 3월 21일
For debugging,
cd('/Users/robinthompson/Documents/JTBWhenIsEpidemicOverPaper');
dinfo = dir('*Results_18351555Time_212.txt');
for K = 1 : length(dinfo)
fprintf('Visible file name: "%s"\n', dinfo(K).name);
fprintf('Numeric equivalent: ');
disp(dinfo(K).name + 0);
fprintf('\n');
end
and show us the result
Robin Thompson
Robin Thompson 2019년 3월 21일
Hi Walter, thanks for your help - please see attached screenshot!
Thanks, RobintoWalter.jpg

댓글을 달려면 로그인하십시오.

답변 (3개)

Robin Thompson
Robin Thompson 2019년 3월 21일
When I run this from a script (rather than command window), I get:
help
Visible file name: "⁨MCMCResults_18351555Time_212.txt"
Numeric equivalent: Columns 1 through 8
8296 77 67 77 67 82 101 115
Columns 9 through 16
117 108 116 115 95 49 56 51
Columns 17 through 24
53 49 53 53 53 84 105 109
Columns 25 through 32
101 95 50 49 50 46 116 120
Column 33
116
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 3월 21일
The 8296 is unicode U+2068, "First Strong Isolate", which is sort of explained in the above link.
It is not at all clear where that came from. It might or might not be related to the fact that U+2068 could be broken up into space and 'h' -- that is, if a section of code was confused over whether a character vector was "wide" characters or not, then plausibly it might have tried to store space and 'h' there but accidentally ended up with U+2068 . But there is no apparent reason why your code might have wanted to store space 'h' .

댓글을 달려면 로그인하십시오.


Robin Thompson
Robin Thompson 2019년 3월 21일
And the weird rectangle is in front of the filename!
toWalter2.jpg

Robin Thompson
Robin Thompson 2019년 3월 22일
Still no luck fixing this - if anyone has any ideas, I would be really grateful! Thanks! Robin
  댓글 수: 6
Walter Roberson
Walter Roberson 2019년 3월 22일
Time to use the debugger to see what the c_str returns. If it is okay then it would be time to debug Ntime4.open
Walter Roberson
Walter Roberson 2019년 3월 22일
Also, when you did the cout, did you happen to pipe the output to "od" or write it to a file and check the contents of the file in detail? With it being a non-printing non-spacing character, there is the possibility that it is there but just did not display in that context.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by