UTF-8 (Chinese) and Trac with svn-mailer on Ubuntu (Also fixes =3D=3D=3D error…)

If you’re doing development of software in China, you’ll almost certainly know you’re way around encodings. If you don’t, you better learn quick 🙂

If you’re using subversion to manage your software version control, then you’ll probably also want to use Trac access an easy to navigate, visual, color view of your source code repository. Additionally, you’ll probably want to use svn-mailer to send out notification messages to the entire development team about each new change as it comes up. Well, if on your Ubuntu box you just do an:

$ sudo aptitude install svnmailer

You’ll be unpleasantly surprised that you’re messages get mutilated… Additionally, Trac URLs is only supported in svn-mailer 1.10 and later. You might install the svnmailer package just to take care of any dependancies, but you’ll want to download the source version and install it too (at least until later 2007 when I would expect the svnmailer package to be in the Ubuntu base distribution).

wget http://storage.perlig.de/svnmailer/svnmailer-1.1.0-dev-r1373.tar.bz2
tar -jxvf svnmailer-*.bz2
cd svnmailer-* && sudo python setup.py install

Next, you’ll want to create an svnmailer.conf file that looks something like this:

[general]
smtp_host = localhost:25
config_charset = utf-8

[defaults]
commit_subject_prefix = [svn] commit:
apply_charset_property = yes
show_applied_charset = yes
from_addr = svn@example.org
to_addr = epsilon@example.org delta@example.org gamma@example.org
browser_base_url = Trac http://example.org/trac/example/browser/
mail_transfer_encoding = 8bit

Note that if you specify a mail_transfer_encoding other than 8bit, you’re messages will almost certainly get mangled… But try it if you like. Note that if you we’re seeing the equals sign (=) being replaced with =3D=3D=3D=3D… in your svn-mailer files, setting the mailer_transfer_encoding to 8bit will also fix that!

Next, you’ll want to cd inside of the root of a copy of your svn checkout and run:

svn pedit svnmailer:content-charset .

(Note the “.” at the end of this line) Next, a window of vim or some other editor should come up, in which you probably want to type:

* = utf-8

That’s it. Save and quit out of your editor, then svn ci the root directory of your checkout. Afterward, you should see that from svn-mailer’s prospective you’re files are by default encoded with UTF-8. You can change the encoding for any subdirectory, while will be inherited by descendants if you need to use some other encoding. You can also write the encoding for a specific file with:

svn pset svnmailer:content-charset utf-8 somefile

<

p>That’s it. You can read more about the svnmailer character set options in the apply_charset_property section of the svnmailer documentation.

Technorati Tags: , ,

2 thoughts on “UTF-8 (Chinese) and Trac with svn-mailer on Ubuntu (Also fixes =3D=3D=3D error…)”

  1. Howdy just wanted to give you a quick heads up. The words in your article seem to be running off the screen in Opera. I’m not sure if this is a formatting issue or something to do with browser compatibility but I thought I’d post to let you know. The style and design look great though! Hope you get the issue fixed soon. Thanks

  2. Hello I am so grateful I found your website, I really found you by mistake, while I was researching on Google for something else, Regardless I am here now and would just like to say thanks for a fantastic post and a all round interesting blog (I also love the theme/design), I don’t have time to read it all at the minute but I have saved it and also added in your RSS feeds, so when I have time I will be back to read more, Please do keep up the great jo.

Leave a Reply

Your email address will not be published. Required fields are marked *