All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: "Jeff King" <peff@peff.net>, "Junio C Hamano" <gitster@pobox.com>,
	"Thomas Haller" <thom311@gmail.com>,
	"Git List" <git@vger.kernel.org>,
	"Torsten Bögershausen" <tboegi@web.de>
Subject: Re: [PATCH ] t4210-log-i18n: spell encoding name "UTF-8" correctly
Date: Mon, 25 Feb 2013 19:54:47 +0100	[thread overview]
Message-ID: <512BB377.2010403@web.de> (raw)
In-Reply-To: <512B22DE.9070603@viscovery.net>

On 25.02.13 09:37, Johannes Sixt wrote:
> From: Johannes Sixt <j6t@kdbg.org>
> 
> iconv on Windows does not know the encoding name "utf8", and does not
> re-encode log messages when this name is given. Request "UTF-8" encoding.
> 
> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
> ---
>  I'm not sure whether I'm right to say that "UTF-8" is the correct
>  spelling. Anyway, 'iconv -l' on my old Linux box lists "UTF8", but on
>  Windows it does not.
> 
>  A more correct fix would probably be to use is_encoding_utf8() in more
>  places, but it's outside my time budget look after it.
> 
>  -- Hannes
> 
>  t/t4210-log-i18n.sh | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/t/t4210-log-i18n.sh b/t/t4210-log-i18n.sh
> index 52a7472..b1956e2 100755
> --- a/t/t4210-log-i18n.sh
> +++ b/t/t4210-log-i18n.sh
> @@ -15,7 +15,7 @@ test_expect_success 'create commits in different encodings' '
>  	t${utf8_e}st
>  	EOF
>  	git add msg &&
> -	git -c i18n.commitencoding=utf8 commit -F msg &&
> +	git -c i18n.commitencoding=UTF-8 commit -F msg &&
>  	cat >msg <<-EOF &&
>  	latin1
>  
> @@ -30,7 +30,7 @@ test_expect_success 'log --grep searches in log output encoding (utf8)' '
>  	latin1
>  	utf8
>  	EOF
> -	git log --encoding=utf8 --format=%s --grep=$utf8_e >actual &&
> +	git log --encoding=UTF-8 --format=%s --grep=$utf8_e >actual &&
>  	test_cmp expect actual
>  '
>  
> @@ -45,7 +45,7 @@ test_expect_success 'log --grep searches in log output encoding (latin1)' '
>  
>  test_expect_success 'log --grep does not find non-reencoded values (utf8)' '
>  	>expect &&
> -	git log --encoding=utf8 --format=%s --grep=$latin1_e >actual &&
> +	git log --encoding=UTF-8 --format=%s --grep=$latin1_e >actual &&
>  	test_cmp expect actual
>  '
>  
> 
Hej,
(beside that I couldn't find t4210 somewhere),
is it something like the following you are tinking of?

(Not sure if my cut-and-paste stuff applies, its's rather for review)

-- >8 --
[PATCH] iconv_open(): Use UTF-8 if UTF8 failes

When iconv_open() failes with EINVAL, it may be that "UTF-8"
is spelled wrong by mistake.
For example, "UTF8" is used instead of "UTF-8".
Some iconv implementations tolerate "UTF8" or "utf8".
If not, iconv_open() fails.
If is_encoding_utf8() is true change the string to the
offical string "UTF-8" with uppercase letters.

Reported-By: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
 utf8.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/utf8.c b/utf8.c
index a4ee665..e9850d0 100644
--- a/utf8.c
+++ b/utf8.c
@@ -487,6 +487,10 @@ char *reencode_string(const char *in, const char *out_encoding, const char *in_e
 	if (!in_encoding)
 		return NULL;
 	conv = iconv_open(out_encoding, in_encoding);
+	if (conv == (iconv_t) -1 && errno == EINVAL) {
+		conv = iconv_open(is_encoding_utf8(out_encoding) ? "UTF-8" : out_encoding,
+											is_encoding_utf8(in_encoding) ? "UTF-8" : in_encoding);
+	}
 	if (conv == (iconv_t) -1)
 		return NULL;
 	out = reencode_string_iconv(in, strlen(in), conv);
-- 
1.8.1.1

  parent reply	other threads:[~2013-02-25 18:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-08 23:52 segfault for git log --graph --no-walk --grep a Thomas Haller
2013-02-09  0:05 ` Junio C Hamano
2013-02-09  0:22   ` Junio C Hamano
2013-02-09  0:27     ` Jeff King
2013-02-09  0:39       ` Junio C Hamano
2013-02-09  0:47         ` Junio C Hamano
2013-02-09  1:05           ` Jeff King
2013-02-09  1:08             ` Jeff King
2013-02-11 19:16           ` Jeff King
2013-02-11 20:01             ` Junio C Hamano
2013-02-11 20:36               ` Junio C Hamano
2013-02-11 20:41                 ` Jeff King
2013-02-11 20:55                   ` Junio C Hamano
2013-02-11 20:59               ` [PATCH] log: re-encode commit messages before grepping Jeff King
2013-02-11 21:11                 ` Junio C Hamano
2013-02-11 21:14                   ` Jeff King
2013-02-25  8:37                 ` [PATCH ] t4210-log-i18n: spell encoding name "UTF-8" correctly Johannes Sixt
2013-02-25 15:19                   ` Jeff King
2013-02-25 19:06                     ` Junio C Hamano
2013-02-25 20:31                       ` Jeff King
2013-02-26  6:47                         ` Johannes Sixt
2013-02-25 21:00                     ` Torsten Bögershausen
2013-02-25 18:54                   ` Torsten Bögershausen [this message]
2013-02-25 20:36                     ` Jeff King
2013-02-09  0:29     ` segfault for git log --graph --no-walk --grep a Junio C Hamano
2013-02-09  0:39       ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=512BB377.2010403@web.de \
    --to=tboegi@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    --cc=peff@peff.net \
    --cc=thom311@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.