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

[PATCH 2/2] git-send-email: use locale encoding for compose

From
KMKrzysztof Mazur <krzysiek@podlesie.net>
Date
Oct 3, 2012, 22:05 UTC
Message-ID
<1349301931-11912-2-git-send-email-krzysiek@podlesie.net>
In-Reply-To
<1349301931-11912-1-git-send-email-krzysiek@podlesie.net>

The introduction email (--compose option) use UTF-8 as default encoding. The current locale encoding is much better default value.

Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
---
 git-send-email.perl | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 107e814..139bb35 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -590,6 +590,16 @@ sub get_patch_subject {
 	die "No subject line in $fn ?";
 }
 
+sub locale_encoding {
+	my $encoding = "UTF-8";
+	eval {
+		require I18N::Langinfo;
+		I18N::Langinfo->import(qw(langinfo CODESET));
+		$encoding = langinfo(CODESET());
+	};
+	return $encoding;
+}
+
 if ($compose) {
 	# Note that this does not need to be secure, but we will make a small
 	# effort to have it be unique
@@ -643,7 +653,7 @@ EOT
 		} elsif (/^\n$/) {
 			$in_body = 1;
 			if (!defined $compose_encoding) {
-				$compose_encoding = "UTF-8";
+				$compose_encoding = locale_encoding();
 			}
 			if ($need_8bit_cte) {
 				print $c2 "MIME-Version: 1.0\n",
-- 
1.7.12.2.2.g1c3c581
Previous: Krzysztof MazurNext: Junio C Hamano
Message 2 of 4 in “git-send-email: introduce compose-encoding”
  1. 1/2 git-send-email: introduce compose-encodingKrzysztof Mazur, Oct 3, 2012
  2. 2/2 git-send-email: use locale encoding for composeKrzysztof Mazur, Oct 3, 2012
  3. Junio C HamanoOct 9, 2012
  4. Krzysztof MazurOct 9, 2012

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.