Add textutils.decode() for safe and configurable text decoding

Also add configuration option for "default encodings" to attempt to
decode text as.  This is in no way a complete fix, but it's better
than having the same list of "default encodings" hard-coded in the
source.
Use urllib.unquote instead of own equivalent implementation

Also assume that URI parameters are UTF-8.  All our pages are
delivered as UTF-8, and ECMAScript's encodeURI{,Component} which
we use sometimes always encodes as UTF-8, so there's no reason
to think it isn't, and in particular, no reasonable alternative
interpretation of non-UTF-8 input.
Drop utf8utils.convertUTF8() in favor of textutils.decode()

The latter has a configurable set of encodings to try, and otherwise
does the same job (and in the default configuration, does the exact
same thing) except it returns a unicode string instead of an UTF-8
encoded byte string.
Improve handling of non-ascii path names

This is not really a good solution.  Long-term we should reduce our
dependency on the "human-readable" aspects of the output from "git diff".
The particular "path munging" that we undo here could be disabled using
the -z argument to "git diff", but that only works together with --raw
(and some other flags) so requires some other changes as well.
Add regression test for /showcommit crash on non-ascii filenames
Fix location of errors (as reported by testing.expect.check())

The stack returned by traceback.extract_stack() is ordered with
the current stack frame last.  We're looking for the nearest frame
under testing/tests/, so should look at the list in reversed order
(IOW, picking the last interesting frame, not the first.)
Fix line diff analysis on lines with non-ASCII characters

Previously, the UTF-8 encoded byte sequence was diffed.  This works well
enough on ASCII input, and on some non-ASCII input, but risks splitting
up multibyte characters when inserting the diff markup later on, if the
differ decides that some but not all bytes of a multibyte character were
modified.

To avoid this, decode the lines as UTF-8 first so that we get unicode
strings to do the diffing on.  Produce byte offsets as the final result
by encoding the unicode strings as UTF-8 again at the end.
Fix line diff markup insertion on lines with non-ASCII characters

The input may have gone through htmlutils.htmlify(), which replaces
non-ASCII characters with decimal entity references (&#nnn;).  We need
to reverse this conversion to get a string that matches the line diff
offsets used to insert the line diff markup.
Reformat some code for increased readability
Add basic test for diffs containing non-ASCII characters