Azzera filtri
Azzera filtri

websave (webread or similar) special characters issue

9 visualizzazioni (ultimi 30 giorni)
fransec il 13 Set 2022
Risposto: Vatsal il 4 Ott 2023
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
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
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 Commenti
Jan il 13 Set 2022
Modificato: Jan il 13 Set 2022
The special character is not just refused by Matlab, but webservers provide encoded characters also. If you insert the string "á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 il 13 Set 2022
"Or any way to transform the special characters in normal ones?"
That is exactly what URL encoding does:

Accedi per commentare.

Risposte (1)

Vatsal il 4 Ott 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 "" class in MATLAB can be used to encode the special characters in a URL.
You can also refer to the MATLAB documentation for "" to obtain more information on its usage and syntax. The link is provided below: -
I hope this helps!

Community Treasure Hunt

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

Start Hunting!

Translated by