]> Lady’s Gitweb - Gitweb/commit
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)
commite0794c82b3b3769fd4c646ba0c7613f28b3983b5c45c016948b9b29c6dffc7f8
tree84902fe936949a5972a0981bfc964e14b1de1b22a9d20474d321560db9ef29b7
parent82fe7d0b840b89b0ae5c3351e928daef0ec9ef630542cd026040b3333adcf03f
gitweb: apply fallback encoding before highlight

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>
gitweb.perl
This page took 0.294916 seconds and 5 git commands to generate.