[PATCH] filter: set environment variable PYTHONIOENCODING to utf-8

John Keeping john at keeping.me.uk
Sun Mar 12 18:51:53 CET 2017


On Sun, Mar 12, 2017 at 10:01:10AM -0700, Jason A. Donenfeld wrote:
> Sorry for the delay. I'm currently on the road traveling and won't be
> properly back at my desk until the end of next week.
> 
> However, my initial reaction is that hard coding various
> interpreter-specific environment variables in cgit itself is not
> correct, and that this is something better left to the CGI environment
> as it sees fit. However, we may benefit from explicit script level
> configuration of unicode stuff.

While I'm inclined to agree with this, in this particular case we
explicitly encode pages as UTF-8 so there is an argument that we should
be telling child processes that UTF-8 is the correct encoding.

Maybe we should be looking to change LANG instead, but I'm not sure how
reliably we can do that.  Is it safe to do something like:

	const char *lang = getenv("LANG");
	struct strbuf sb = STRBUF_INIT;

	if (!lang)
		lang = "C";
	strbuf_addf(&sb, "%.*s.UTF-8",
		    (int) (strchrnul(lang, '.') - lang), lang);
	setenv("LANG", sb.buf);

?


More information about the CGit mailing list