]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: apply fallback encoding before highlight
authorShin Kojima <redacted>
Tue, 3 May 2016 13:00:51 +0000 (22:00 +0900)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:32 +0000 (00:51 -0400)
Some multi-byte character encodings (such as Shift_JIS and GBK) have
characters whose final bytes is an ASCII '\' (0x5c), and they
will be displayed as funny-characters even if $fallback_encoding is
correct.  This is because `highlight` command always expects UTF-8
encoded strings from STDIN.

    $ echo 'my $v = "申";' | highlight --syntax perl | w3m -T text/html -dump
    my $v = "申";

    $ echo 'my $v = "申";' | iconv -f UTF-8 -t Shift_JIS | highlight \
        --syntax perl | iconv -f Shift_JIS -t UTF-8 | w3m -T text/html -dump

    iconv: (stdin):9:135: cannot convert
    my $v = "

This patch prepare git blob objects to be encoded into UTF-8 before
highlighting in the manner of `to_utf8` subroutine.

Signed-off-by: Shin Kojima <redacted>
Reviewed-by: Jakub Narębski <redacted>
Signed-off-by: Junio C Hamano <redacted>

No differences found
This page took 0.195348 seconds and 4 git commands to generate.