From: Johannes Sixt Date: Tue, 26 Feb 2013 06:47:39 GMT Subject: Re: [PATCH ] t4210-log-i18n: spell encoding name "UTF-8" correctly Message-ID: <512C5A8B.9070302@viscovery.net> In-Reply-To: <20130225203100.GA15932@sigill.intra.peff.net> Am 2/25/2013 21:31, schrieb Jeff King: > Subject: [PATCH] utf8: accept alternate spellings of UTF-8 > ... > JSixt, can you double-check that this passes t4210 for you? Yes, t4210 and all other *i18n* and *log* tests pass with this patch. Thanks, -- Hannes > > utf8.c | 20 ++++++++++++++++++-- > 1 file changed, 18 insertions(+), 2 deletions(-) > > diff --git a/utf8.c b/utf8.c > index 1087870..8f6e84b 100644 > --- a/utf8.c > +++ b/utf8.c > @@ -507,9 +507,25 @@ 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) > - return NULL; > + if (conv == (iconv_t) -1) { > + /* > + * Some platforms do not have the variously spelled variants of > + * UTF-8, so let's fall back to trying the most official > + * spelling. We do so only as a fallback in case the platform > + * does understand the user's spelling, but not our official > + * one. > + */ > + if (is_encoding_utf8(in_encoding)) > + in_encoding = "UTF-8"; > + if (is_encoding_utf8(out_encoding)) > + out_encoding = "UTF-8"; > + conv = iconv_open(out_encoding, in_encoding); > + if (conv == (iconv_t) -1) > + return NULL; > + } > + > out = reencode_string_iconv(in, strlen(in), conv); > iconv_close(conv); > return out;