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

Re: non-US-ASCII file names (e.g. Hiragana) on Windows

From
Shawn O. Pearce <spearce@spearce.org>
Date
Dec 1, 2009, 16:26 UTC
Message-ID
<20091201162627.GE21299@spearce.org>
In-Reply-To
<4B14EB2E.9020906@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 9 quoted lines
> Thomas Singer schrieb:
> > To be more precise: Who is interpreting the bytes in the file names as
> > characters? Windows, Git or Java?
> 
> In the case of git: Windows does it, using the console's codepage to
> convert between bytes and Unicode.
> 
> I don't know about Java, but I guess that no conversion is necessary
> because Java is Unicode-aware.

Actually, conversion is necessary, and its something that is proving to be really painful within JGit.

The Java IO APIs use UTF-16 for file names. However we are reading a stream of unknown bytes from the index file and tree objects. Thus JGit must convert a stream of bytes into UTF-16 just to get to the OS.

The JVM then turns around and converts from UTF-16 to some other encoding for the filesystem.

On Win32 I suspect the JVM uses the native UTF-16 file APIs, so this translation is lossless.

On POSIX, I suspect the JVM uses $LANG or some other related environment variable to guess the user's preferred encoding, and then converts from UTF-16 to bytes in that encoding. And I have no idea how they handle normalization of composed code points.

All of these layers make for a *very* confusing situation for us within JGit:

  git tree
  +---------+
  | bytes   | -+
  +---------+   \
                 \             +--------+            +---------+
                  +-- JGit --> | UTF-16 | -- JVM --> | OS call |
  .git/index     /             +--------+            +---------+
  +---------+   /
  | bytes   | -+
  +---------+

Its impossible for us to do what C git does, which is just use the bytes used by the OS call within the git datastructure. Which of course also isn't always portable, e.g. the Mac OS X HFS+ mess.

:-)
-- 
Shawn.
Previous: Johannes SixtNext: Robin Rosenberg
Message 6 of 27 in “non-US-ASCII file names (e.g. Hiragana) on Windows”
  1. Thomas SingerNov 28, 2009
  2. Johannes SixtNov 28, 2009
  3. Thomas SingerDec 1, 2009
  4. Thomas SingerDec 1, 2009
  5. Johannes SixtDec 1, 2009
  6. Shawn O. PearceDec 1, 2009
  7. Robin RosenbergDec 1, 2009
  8. Maximilien NoalNov 28, 2009
  9. Thomas SingerNov 29, 2009
  10. Thomas SingerDec 1, 2009
  11. Johannes SixtDec 1, 2009
  12. Thomas SingerDec 1, 2009
  13. Johannes SixtDec 1, 2009
  14. Thomas SingerDec 1, 2009
  15. Johannes SixtDec 1, 2009
  16. Thomas SingerDec 1, 2009
  17. Erik Faye-LundDec 1, 2009
  18. Thomas SingerDec 1, 2009
  19. brad12Oct 30, 2010
  20. Jakub NarebskiOct 30, 2010
  21. Jakub NarebskiDec 1, 2009
  22. Thomas SingerDec 1, 2009
  23. Shawn PearceDec 2, 2009
  24. demerphqOct 30, 2010
  25. Erik Faye-LundDec 1, 2009
  26. Thomas SingerDec 1, 2009
  27. Reece DunnNov 28, 2009

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.