websave (webread or similar) special characters issue
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
hello,
I have a problem using the function websave with names including special characters.
I need to download from https to my personal PC a file containing in its name some special characters, here an example
websave('https://www.anyservice.it/Xápar_KK.mat')
where Xápar contains the á character which is not supported by websave. The result given by Matlab is:
Error using matlab.internal.webservices.HTTPConnector/copyContentToFile (line 389)
The server returned the status 404 with message "Not Found" in response to the request to URL
https://www.anyservice.it/X%C3%A1par_KK.mat.
Error in websave (line 107)
copyContentToFile(connection, filename);
Do you know any weboptions to make websave correctly reading the name with special characters, or other Matlab functions usable? Or any way to transform the special characters in normal ones?
Thanks a lot!
2 Kommentare
Jan
am 13 Sep. 2022
Bearbeitet: Jan
am 13 Sep. 2022
The special character is not just refused by Matlab, but webservers provide encoded characters also. If you insert the string "https://www.XYZ.it/Xápar_KK.mat" in a browser, it is converted accordingly also.
Is the shown web page really the concerned location? It is a word press site and very unlikely, that a mat file is found in the home path. If you provide a dummy page only, avoid to use a commercial service because this is considered as spam. Thanks.
Stephen23
am 13 Sep. 2022
"Or any way to transform the special characters in normal ones?"
That is exactly what URL encoding does: https://en.wikipedia.org/wiki/Percent-encoding
Antworten (1)
Vatsal
am 4 Okt. 2023
Hi fransec,
I understand that there is an issue with the "websave" function when attempting to download a file with special characters in its name. To resolve this issue, you can convert the special characters in the filename to their corresponding URL-encoded format. The " matlab.net.URI" class in MATLAB can be used to encode the special characters in a URL.
You can also refer to the MATLAB documentation for "matlab.net.URI" to obtain more information on its usage and syntax. The link is provided below: -
I hope this helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Call Web Services from MATLAB Using HTTP finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!