# HG changeset patch # User Matt Mackall # Date 1165193225 21600 # Node ID 713e35dcc3217aad20bae20b8ca5b25c82d82a71 # Parent d0a48313b0f6509a4186746183a60bf9935b3518 hgweb: report detected character set Add comments on overriding charset to CGI scripts diff -r d0a48313b0f6 -r 713e35dcc321 hgweb.cgi --- a/hgweb.cgi Sun Dec 03 17:28:58 2006 -0600 +++ b/hgweb.cgi Sun Dec 03 18:47:05 2006 -0600 @@ -10,6 +10,13 @@ from mercurial.hgweb.request import wsgiapplication import mercurial.hgweb.wsgicgi as wsgicgi +# If you'd like to serve pages with UTF-8 instead of your default +# locale charset, you can do so by uncommenting the following lines. +# Note that this will cause your .hgrc files to be interpreted in +# UTF-8 and all your repo files to be displayed using UTF-8. +# +# os.environ["HGENCODING"] = "UTF-8" + def make_web_app(): return hgweb("/path/to/repo", "repository name") diff -r d0a48313b0f6 -r 713e35dcc321 hgwebdir.cgi --- a/hgwebdir.cgi Sun Dec 03 17:28:58 2006 -0600 +++ b/hgwebdir.cgi Sun Dec 03 18:47:05 2006 -0600 @@ -29,6 +29,13 @@ # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples # or use a dictionary with entries like 'virtual/path': '/real/path' +# If you'd like to serve pages with UTF-8 instead of your default +# locale charset, you can do so by uncommenting the following lines. +# Note that this will cause your .hgrc files to be interpreted in +# UTF-8 and all your repo files to be displayed using UTF-8. +# +# os.environ["HGENCODING"] = "UTF-8" + def make_web_app(): return hgwebdir("hgweb.config") diff -r d0a48313b0f6 -r 713e35dcc321 mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py Sun Dec 03 17:28:58 2006 -0600 +++ b/mercurial/hgweb/hgweb_mod.py Sun Dec 03 18:47:05 2006 -0600 @@ -654,7 +654,8 @@ def run_wsgi(self, req): def header(**map): - header_file = cStringIO.StringIO(''.join(self.t("header", **map))) + header_file = cStringIO.StringIO( + ''.join(self.t("header", encoding = util._encoding, **map))) msg = mimetools.Message(header_file, 0) req.header(msg.items()) yield header_file.read() diff -r d0a48313b0f6 -r 713e35dcc321 templates/gitweb/header.tmpl --- a/templates/gitweb/header.tmpl Sun Dec 03 17:28:58 2006 -0600 +++ b/templates/gitweb/header.tmpl Sun Dec 03 18:47:05 2006 -0600 @@ -1,11 +1,10 @@ -Content-type: text/html +Content-type: text/html; charset={encoding} - + - diff -r d0a48313b0f6 -r 713e35dcc321 templates/header.tmpl --- a/templates/header.tmpl Sun Dec 03 17:28:58 2006 -0600 +++ b/templates/header.tmpl Sun Dec 03 18:47:05 2006 -0600 @@ -1,4 +1,4 @@ -Content-type: text/html +Content-type: text/html; charset={encoding} diff -r d0a48313b0f6 -r 713e35dcc321 templates/raw/header.tmpl --- a/templates/raw/header.tmpl Sun Dec 03 17:28:58 2006 -0600 +++ b/templates/raw/header.tmpl Sun Dec 03 18:47:05 2006 -0600 @@ -1,1 +1,2 @@ -Content-type: text/plain +Content-type: text/plain; charset={encoding} +