comparison mercurial/hbisect.py @ 28209:8ddf893560fa

templatefilters: add "utf8" to get utf-8 bytes from local-encoding text This will be applied prior to "|json" filter. This sounds like odd, but it is necessary to handle local-encoding text as well as raw filename bytes. Because filenames are bytes in Mercurial and Unix world, {filename|json} should preserve the original byte sequence, which implies {x|json} -> '"' toutf8b(x) '"' On the other hand, most template strings are in local encoding. Because "|json" filter have to be byte-transparent to filenames, we need something to annotate an input as a local string, that's what "|utf8" will do. {x|utf8|json} -> '"' toutf8b(fromlocal(x)) '"' "|utf8" is an explicit call, so aborts if input bytes can't be converted to UTF-8.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 27 Dec 2015 17:45:05 +0900
parents 9b8a5c6ac176
children ee21ed7fc7a2
comparison
equal deleted inserted replaced
28208:f4418ff2f700 28209:8ddf893560fa