git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] send-email: UTF-8 encoding in subject line

From
Philip Oakley <philipoakley@iee.email>
Date
Feb 22, 2026, 14:53 UTC
Message-ID
<335b1189-f5c3-4e7c-ad3a-266810a0ca90@iee.email>
In-Reply-To
<20260222140737.1760413-1-shreyanshpaliwalcmsmn@gmail.com>
On 22/02/2026 14:03, Shreyansh Paliwal wrote:
Show 13 quoted lines
>>> That makes sense, I tried it below.
>>> I also wondered whether, in addition to this, it might be helpful to warn on
>>> an invalid charset, and/or possibly fall back to UTF-8.
>>
>> Agreed on the first half of the statement, if we have an easy and
>> portable way to tell if a given random string names a valid charset.
>> I do not recommend to "fall back" to anything, if we are asking an
>> input from the user.
> 
> Following up on this, I tried adding a warning when the provided charset
> does not appear to be valid. Current flow is,
> 
>   Which 8bit encoding should I declare [UTF-8]? y

Perhaps swap around the 'Which-declare' to "Declare which' to to get away from the obviousness of 'Which' being the classic y/n binary question. Action first?

	Declare which 8bit encoding to use [default:UTF-8]?
Checking validity of the encoding is a reasonable follow on.
Philip
Show 60 quoted lines
>   Are you sure you want to use <y> [y/N]? y
> 
> With the additional check, it becomes,
> 
>   Which 8bit encoding should I declare [default: UTF-8]? y
>   warning: 'y' does not appear to be a valid charset name.
>   Are you sure you want to use <y> [y/N]?
> 
> This uses find_encoding() from Perl’s Encode module to detect any
> unrecognized charset names.
> 
> Let me know what you think.
> Also, is there any new test that should be added for this change?
> 
> Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
> ---
>  git-send-email.perl | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/git-send-email.perl b/git-send-email.perl
> index cd4b316ddc..e62fa259ba 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -23,6 +23,7 @@
>  use Git::LoadCPAN::Error qw(:try);
>  use Git;
>  use Git::I18N;
> +use Encode qw(find_encoding);
>  
>  Getopt::Long::Configure qw/ pass_through /;
>  
> @@ -1044,9 +1045,25 @@ sub file_declares_8bit_cte {
>  	foreach my $f (sort keys %broken_encoding) {
>  		print "    $f\n";
>  	}
> -	$auto_8bit_encoding = ask(__("Which 8bit encoding should I declare [UTF-8]? "),
> -				  valid_re => qr/.{4}/, confirm_only => 1,
> -				  default => "UTF-8");
> +	while (1) {
> +		my $encoding = ask(__("Which 8bit encoding should I declare [default: UTF-8]? "),
> +			valid_re => qr/^\S+$/,
> +			default  => "UTF-8");
> +		next unless defined $encoding;
> +		if (find_encoding($encoding)) {
> +			$auto_8bit_encoding = $encoding;
> +			last;
> +		}
> +		printf STDERR __("warning: '%s' does not appear to be a valid charset name.\n"), $encoding;
> +		my $yesno = ask(
> +			sprintf(__("Are you sure you want to use <%s> [y/N]? "), $encoding),
> +			valid_re => qr/^(?:y|n)/i,
> +			default  => 'n');
> +		if (defined $yesno && $yesno =~ /^y/i) {
> +			$auto_8bit_encoding = $encoding;
> +			last;
> +		}
> +	}
>  }
>  
>  if (!$force) {
Previous: D. Ben KnobleNext: Shreyansh Paliwal
Message 8 of 27 in “[RFC] send-email: UTF-8 encoding in subject line”
  1. Shreyansh PaliwalFeb 20, 2026
  2. Ben KnobleFeb 21, 2026
  3. Shreyansh PaliwalFeb 21, 2026
  4. Junio C HamanoFeb 21, 2026
  5. Shreyansh PaliwalFeb 22, 2026
  6. D. Ben KnobleFeb 22, 2026
  7. D. Ben KnobleFeb 22, 2026
  8. Philip OakleyFeb 22, 2026
  9. Shreyansh PaliwalFeb 22, 2026
  10. Ben KnobleFeb 23, 2026
  11. Shreyansh PaliwalFeb 24, 2026
  12. send-email: validate charset name in 8bit encoding promptShreyansh Paliwal, Feb 24, 2026
  13. Junio C HamanoFeb 24, 2026
  14. send-email: validate charset name in 8bit encoding promptShreyansh Paliwal, Feb 24, 2026
  15. Junio C HamanoFeb 24, 2026
  16. Shreyansh PaliwalFeb 24, 2026
  17. D. Ben KnobleFeb 25, 2026
  18. send-email: validate charset name in 8bit encoding promptShreyansh Paliwal, Feb 26, 2026
  19. Shreyansh PaliwalFeb 26, 2026
  20. Junio C HamanoFeb 26, 2026
  21. Junio C HamanoFeb 26, 2026
  22. Shreyansh PaliwalFeb 28, 2026
  23. Shreyansh PaliwalFeb 28, 2026
  24. send-email: validate charset name in 8bit encoding promptShreyansh Paliwal, Feb 28, 2026
  25. D. Ben KnobleFeb 28, 2026
  26. Junio C HamanoMar 2, 2026
  27. Shreyansh PaliwalMar 3, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.