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!