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

Re: [PATCH 1/2] Fixing file name encoding issues.

From
KKKonstantin Khomoutov <kostix@bswap.ru>
Date
Feb 19, 2025, 17:30 UTC
Message-ID
<20250219173032.x5gzw6hsvsu4flba@carbon>
In-Reply-To
<d33fb3d940cf97bdfe3dc544763a51df4874a5c0.1739918546.git.gitgitgadget@gmail.com>
On Tue, Feb 18, 2025 at 10:42:25PM +0000, Kazuhiro Kato via GitGitGadget wrote:
[...]
Show 12 quoted lines
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index 47a7c1d29c4..88951ed2384 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
> @@ -12379,6 +12379,7 @@ catch {
>  if {$gitencoding == ""} {
>      set gitencoding "utf-8"
>  }
> +encoding system utf-8
>  set tclencoding [tcl_encoding $gitencoding]
>  if {$tclencoding == {}} {
>      puts stderr "Warning: encoding $gitencoding is not supported by Tcl/Tk"

I'm not sure one should sensibly do this - except to implement some well-understood and well-documented kludge, simply because the "system encoding" is supposed to be set by the Tcl runtime.

Let's demonstrate (on a Linux-based system with UTF-8 locale):
  tmp$ touch 'привет мир.txt'
  tmp$ tclsh
  % encoding system
  utf-8
  % glob привет*.txt
  {привет мир.txt}
  % encoding system cp1251
  % encoding system
  cp1251
  % glob привет*.txt
  no files matched glob pattern "привет*.txt"
  %

Here, CP1251 is a Windows "code page" for Cyrillic; it's what [encoding system] reports on Windows systems.

Note that I create a file whose name is two words in Cyrillic script encoded in UTF-8, and Tcl is fine finding and dispaying this file (via its "glob" command). But as soon as I change the Tcl's system encoding to another 8-bit Cyrillic encoding, globbing stops working.

Moreover, if I'd do [glob *.txt] so that my file would be matched anyway, its named would not be readable since Tcl would re-encode it from CP1251 to Unicode, but the name is encoded in UTF-8, not CP1251.

In other words, your patch (supposedly) works on UTF-8-based systems which is common to Linux-based OSes and MacOS, but I'm afraid it won't work on Windows.

Previous: Kazuhiro Kato via GitGitGadgetNext: Junio C Hamano
Message 3 of 7 in “gitk: Fixing file name encoding issues.”
  1. 0/2 gitk: Fixing file name encoding issues.Kazuhiro Kato via GitGitGadget, Feb 18, 2025
  2. 1/2 Fixing file name encoding issues.Kazuhiro Kato via GitGitGadget, Feb 18, 2025
  3. Konstantin KhomoutovFeb 19, 2025
  4. Junio C HamanoFeb 19, 2025
  5. 2/2 fix: when resolving merge conflicts, japanese file names become garbled.Kazuhiro Kato via GitGitGadget, Feb 18, 2025
  6. Junio C HamanoFeb 19, 2025
  7. Junio C HamanoFeb 18, 2025

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.