shinyypig / matlab-in-vscode

A vscode extension for matlab.
MIT License
44 stars 4 forks source link

Non UTF-8 chars are removed from path #6

Closed Accelerox closed 1 year ago

Accelerox commented 1 year ago

First of all, using non UTF8 characters in paths is bad practice, however, I'm in a position where I cant change the paths since they are determined by my University. With that said...

Having a non UTF8 characters in the path won't work when pressing the "Run current matlab file" in vscode. However, running current cell works fine.

Pressing run file yields:

run('/Users/max/Library/CloudStorage/OneDrive-Linkpingsuniversitet/Sensor_Fusion_TSRT14/Lab2/test.m')
Error using run
/Users/max/Library/CloudStorage/OneDrive-Linkpingsuniversitet/Sensor_Fusion_TSRT14/Lab2/test.m not found.

The "ö" in the path has disappeared on closer inspection, real path is equal to

/Users/max/Library/CloudStorage/OneDrive-Linköpingsuniversitet/Sensor_Fusion_TSRT14/Lab2/test.m
shinyypig commented 1 year ago

What is the version of MATLAB and Python you are currently using?

I have tested running a .m file with a path containing non-UTF8 characters, and have found that everything worked fine with MATLAB 2023a and Python 3.9.

Accelerox commented 1 year ago

Sure thing! I conducted two more tests with different settings and got one of them to work. The above test was done with the settings

(base) max@ubuntu:TSRT14-Lab2 $ /usr/local/bin/matlab -nodesktop -nosplash

                                                        < M A T L A B (R) >
                                              Copyright 1984-2023 The MathWorks, Inc.
                                         R2023a Update 1 (9.14.0.2239454) 64-bit (glnxa64)
                                                           March 30, 2023

Warning: X does not support locale en_US.UTF-8

To get started, type doc.
For product information, visit www.mathworks.com.

f>> printf('Working directory: %s\n', pwd);
Working directory: /home/max/Nextcloud/Utbildning/Universitet/4_e aret/TSRT14 - Sensor FusionÖ/TSRT14-Lab2
>> run('/home/max/Nextcloud/Utbildning/Universitet/4_e aret/TSRT14 - Sensor Fusion/TSRT14-Lab2/test.m')
Error using run
/home/max/Nextcloud/Utbildning/Universitet/4_e aret/TSRT14 - Sensor Fusion/TSRT14-Lab2/test.m not found. 
>> 

Doing a third test with Ubuntu and pybackend enabled (wiith a "ö" in path after "Sensor Fusion")

Please let me know if there is any more tests I can do to help with this extension.

shinyypig commented 1 year ago

It seems to be a issue with matlab.

(base) max@ubuntu:TSRT14-Lab2 $ /usr/local/bin/matlab -nodesktop -nosplash

                                                        < M A T L A B (R) >
                                              Copyright 1984-2023 The MathWorks, Inc.
                                         R2023a Update 1 (9.14.0.2239454) 64-bit (glnxa64)
                                                           March 30, 2023

Warning: X does not support locale en_US.UTF-8

Can files with non-UTF-8 characters in their paths be run directly from the Matlab command line?

Accelerox commented 1 year ago

Yeah, the command

run('/home/max/Nextcloud/Utbildning/Universitet/4_e aret/TSRT14 - Sensor FusionÖ/TSRT14-Lab2/test.m')

with the Ö works fine from within the program matlab command prompt, and from within the matlab terminal opened by the extension in vscode.

Correct me if im'm wrong. butt since the extension is "building" the run command (without the ö) it should be the extension having problem with the char? As we can see from test 2: The run command is wrongly built, which gets generated from pressing the "run" button from within vscode.

>>> run('/home/max/Nextcloud/Utbildning/Universitet/4_e aret/TSRT14 - Sensor Fusion/TSRT14-Lab2/test.m')

However, I agree that the error message regarding locale support is weird, however Mathworks says it should have no functionality changes https://www.mathworks.com/matlabcentral/answers/1925710-warning-x-does-not-support-locale-en_us-utf-8

EDIT: It works only if im using the python matlab engine, swapping back to without it, the problem seems to be that I can't paste the command in to the terminal - so it seems you are right, the matlab terminal ommits the Ö without the python engine.