curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder Daniel himself.

Re: FR: curl CLI: -O/--remote-name: Decode output filename

From: Dan Fandrich via curl-library <curl-library_at_lists.haxx.se>
Date: Sat, 10 Aug 2024 22:45:11 -0700

On Sun, Aug 11, 2024 at 04:39:52AM +0300, Samuel Henrique via curl-library wrote:
> This feature request comes from a discussion we've had in wcurl:
> https://salsa.debian.org/debian/wcurl/-/merge_requests/4
>
> It's about performing the decoding of the output filename when -O is used, so
> for example, if I call:
> $ curl -O example.com/filename%20with%20spaces.txt
> I would like to be able to get as the output file:
> "filename with spaces.txt" instead of "filename%20with%20spaces.txt".

The big problem with this is character set conversion. If the URL is in UTF-8
and the user's filesystem is in CP1252, this will produce a garbage file name.
Or even worse, the other way around which could result in a file that's not
even accessible by some software. Since there's no way to tell what character
set the URL is in, this seems impossible to do correctly. Unless you're
suggesting just handling characters in the range 0x20-0x7e or something along
those lines, but that could result in confused users when some files are
converted and some are not.

Dan
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2024-08-11