problem with print - "file name contains characters that are not contained in the filesystem encoding"
2 views (last 30 days)
Show older comments
The operation
>> file = 'C:\Users\fbo\Documents\test.png';
>> print(file);
leads to
Error using fopen The file name contains characters that are not contained in the filesystem
encoding. Certain operations may not work as expected.
Error in name (line 84)
fidread = fopen(pj.FileName,'r');
Error in print (line 197)
pj = name( pj );
Error in print
Howeverer, the command
>> file = 'test.png';
>> print(file)
works fine.
Searching the web for a solution resulted in the command
>> restoredefaultpath
and I was then able to execute the print command. But the restoredefaultpath command also removed a lot of useful paths that are no longer available.
So, how can I keep all my paths and have the print command working?
Cheers,
Fredrik
0 Comments
Answers (1)
Steven Lord
on 16 Sep 2015
The fact that RESTOREDEFAULTPATH resolved the issue makes me suspect that you have an FOPEN on one of those "useful paths" that is shadowing the FOPEN function included with MATLAB. What does this command show?
which -all fopen
You should see the built-in FOPEN function, a serial method, and possibly (depending what toolboxes you have installed) an icinterface method and an i2c method. If you see something else that is NOT part of a MathWorks product listed, try removing the directory containing that file from the MATLAB path and try printing again.
Alternately if you want to see for certain which FOPEN is being used, set a breakpoint in the private helper function name using this command, then try to PRINT again:
dbstop in private/name at 84
When you reach that breakpoint, execute:
dbstep in
If I'm correct in my suspicion, it will go into the FOPEN that's shadowing the built-in version.
Once you've finished debugging, clear all the breakpoints using this command, so you don't have to go past that breakpoint every time you call PRINT later in that session of MATLAB:
dbclear all
2 Comments
Walter Roberson
on 17 Sep 2015
Another possibility is that you have a name.m or print.m that is interfering with the expected versions.
See Also
Categories
Find more on Search Path in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!