From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Marcin Cieslak <saper@saper.info>,
Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: Odd encoding issue with UTF-8 + gettext yields ? on non-ASCII
Date: Mon, 30 Aug 2010 14:33:24 +0000 [thread overview]
Message-ID: <AANLkTik-7FCm-WLOKOKd5uA9astMXtdZZLTT=0euX5RL@mail.gmail.com> (raw)
In-Reply-To: <20100830140958.GE2315@burratino>
On Mon, Aug 30, 2010 at 14:09, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Marcin Cieslak wrote:
>
>> Well, in this case everybody will be force to have UTF-8 in output
>> on-screen, not useful for people using ISO8859-*, KOI8-R and similar
>> things...
>
> Can't we do:
>
> setlocale(LC_CTYPE, "");
> charset = nl_langinfo(CODESET);
> setlocale(LC_CTYPE, "C");
>
> to allow an arbitrary character set?
Yes, it seems so! With this patch:
--- a/gettext.c
+++ b/gettext.c
@@ -3,2 +3,3 @@
#include <libintl.h>
+#include <langinfo.h>
#include <stdlib.h>
@@ -8,2 +9,3 @@ extern void git_setup_gettext(void) {
char *envdir = getenv("GIT_TEXTDOMAINDIR");
+ char *charset;
@@ -19,2 +21,6 @@ extern void git_setup_gettext(void) {
(void)setlocale(LC_MESSAGES, "");
+ (void)setlocale(LC_CTYPE, "");
+ charset = nl_langinfo(CODESET);
+ (void)bind_textdomain_codeset("git", charset);
+ (void)setlocale(LC_CTYPE, "C");
(void)textdomain("git");
The sanity test still passes:
./t0201-gettext-fallbacks.sh ......... ok
./t0200-gettext-basic.sh ............. ok
./t0203-gettext-setlocale-sanity.sh .. ok
./t0202-gettext-perl.sh .............. ok
All tests successful.
And the resulting git binary can emit both UTF-8 and ISO-8859-1 text
from its *.po files, respectively:
Bjó til tóma Git lind í /tmp/meh/.git/
Bj� til t�ma Git lind � /tmp/meh/.git/
next prev parent reply other threads:[~2010-08-30 14:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-28 21:17 Odd encoding issue with UTF-8 + gettext yields ? on non-ASCII Ævar Arnfjörð Bjarmason
2010-08-28 21:33 ` Ævar Arnfjörð Bjarmason
2010-08-28 21:46 ` Jonathan Nieder
2010-08-28 21:59 ` Jonathan Nieder
2010-08-28 22:14 ` Marcin Cieslak
2010-08-28 22:16 ` Jonathan Nieder
2010-08-29 7:36 ` Ævar Arnfjörð Bjarmason
2010-08-29 8:37 ` Ævar Arnfjörð Bjarmason
2010-08-30 2:22 ` Jonathan Nieder
2010-08-29 18:12 ` Ævar Arnfjörð Bjarmason
2010-08-29 20:45 ` Jonathan Nieder
2010-08-30 8:57 ` Ævar Arnfjörð Bjarmason
2010-08-30 13:41 ` Jonathan Nieder
2010-08-30 14:00 ` Marcin Cieslak
2010-08-30 14:09 ` Jonathan Nieder
2010-08-30 14:33 ` Ævar Arnfjörð Bjarmason [this message]
2010-08-30 14:13 ` Ævar Arnfjörð Bjarmason
2010-08-30 14:04 ` Ævar Arnfjörð Bjarmason
2010-08-28 22:20 ` Jonathan Nieder
2010-08-28 22:30 ` Marcin Cieslak
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='AANLkTik-7FCm-WLOKOKd5uA9astMXtdZZLTT=0euX5RL@mail.gmail.com' \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=saper@saper.info \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).