websave (webread or similar) special characters issue
조회 수: 6 (최근 30일)
이전 댓글 표시
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
Jan
2022년 9월 13일
편집: Jan
2022년 9월 13일
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
2022년 9월 13일
"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
답변 (1개)
Vatsal
2023년 10월 4일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!