git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gitweb: Measure offsets against UTF-8 flagged string

From
Shin Kojima <shin@kojima.org>
Date
May 3, 2018, 15:16 UTC
Message-ID
<20180503151627.45pt2veqcjzbk44q@skmbp>
In-Reply-To
<86k1skzzc4.fsf@gmail.com>
Show 5 quoted lines
> One solution would be to force conversion to UTF-8 on input via "open"
> pragma (e.g. "use open ':encoding(UTF-8)';").  But there is no
> UTF-8-with_fallback encoding available - we would have to write one, and
> install it as module (or fake it via Perl trickery).  This mechanism is
> almost the same to what we currently use in gitwbe.

Yes, I tried using `Encode::Guess` with "open" pragma, but no luck. https://perldoc.perl.org/Encode/Guess.html

I'm also afraid of "open" pragma does not work properly while using git_blame_common(). Let's say someone using non-ASCII characters in his/her name, committing non-UTF8 encoded characters. git-blame will combine them in the same line. Following is an example:

$ git blame dummy | xxd 00000000: 3461 6464 3565 6331 2028 e585 90e5 b3b6 4add5ec1 (...... 00000010: 20e6 96b0 2032 3031 382d 3035 2d30 3320 ... 2018-05-03 00000020: 3232 3a34 383a 3432 202b 3039 3030 2031 22:48:42 +0900 1 00000030: 2920 8367 8389 8343 0a ) .g...C.

    * e585 90e5 b3b6 20e6 96b0 : my name, encoded with UTF-8
    * 8367 8389 8343           : "トライ" encoded with Shift_JIS

It means I need to split each lines of git-blame output at the very beginning, then convert the first-half as UTF-8 and the second-half as Shift_JIS.

Sincerely,
-- 
Shin Kojima
Previous: Jakub NarebskiNext: Junio C Hamano
Message 5 of 6 in “gitweb: Measure offsets against UTF-8 flagged string”
  1. gitweb: Measure offsets against UTF-8 flagged stringShin Kojima, May 1, 2018
  2. Junio C HamanoMay 2, 2018
  3. Shin KojimaMay 2, 2018
  4. Jakub NarebskiMay 3, 2018
  5. Shin KojimaMay 3, 2018
  6. Junio C HamanoMay 4, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.