Enigma icon indicating copy to clipboard operation
Enigma copied to clipboard

Errors when trying to read a directory with Japanese filenames

Open PseudoDistant opened this issue 3 years ago • 9 comments

Exception in thread "Basic L&F File Loading Thread" java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: /home/distant/???????????????????????? at java.base/sun.nio.fs.UnixPath.encode(UnixPath.java:121) at java.base/sun.nio.fs.UnixPath.(UnixPath.java:68) at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:279) at java.base/java.nio.file.Path.of(Path.java:147) at java.base/java.nio.file.Paths.get(Paths.java:69) at java.desktop/sun.awt.shell.ShellFolder.getShellFolder(ShellFolder.java:265) at java.desktop/javax.swing.filechooser.FileSystemView.getFiles(FileSystemView.java:585) at java.desktop/javax.swing.plaf.basic.BasicDirectoryModel$FilesLoader.run0(BasicDirectoryModel.java:306) at java.desktop/javax.swing.plaf.basic.BasicDirectoryModel$FilesLoader.run(BasicDirectoryModel.java:295) at java.base/java.lang.Thread.run(Thread.java:833)

I had a Tiny file in my home, but it refused to read the folder and spammed this in console until I moved the non-Latin files.

PseudoDistant avatar Apr 08 '22 02:04 PseudoDistant

Hmm, I typed some random Japanese through google translate for directory name, and I can load it with enigma. I am on windows and java 17. Unfortunately I don't have a linux environment to test. java 18 has a utf-8 by default feature (jep 400); can you try with java 18?

Also make sure your directory names are in some compatible encoding. I know some non-english file names can have their names messed up, such as after extraction from zip or rar files.

liach avatar Apr 08 '22 04:04 liach

@liach I have the same problem on Java 18, and the file names are in Katakana. However I've been able to confirm that it also fails with Chinese and Korean filenames as well.

PseudoDistant avatar Apr 08 '22 06:04 PseudoDistant

Might be a system locale issue, I've encountered problems with non-ascii file names when the locale was set up incorrectly (e.g. using a non-UTF8 locale or a locale that doesn't exist on the system because it wasn't generated or something like that), though I don't know if Java uses libc locale at all in any way. What's the output of running locale in a terminal?

2xsaiko avatar Apr 08 '22 10:04 2xsaiko

Might be a system locale issue, I've encountered problems with non-ascii file names when the locale was set up incorrectly (e.g. using a non-UTF8 locale or a locale that doesn't exist on the system because it wasn't generated or something like that), though I don't know if Java uses libc locale at all in any way. What's the output of running locale in a terminal? locale -a

PseudoDistant avatar Apr 08 '22 20:04 PseudoDistant

Yeah those "No such file or directory" messages do seem like that is the problem. Could you also send the output of locale?

2xsaiko avatar Apr 08 '22 20:04 2xsaiko

Yeah those "No such file or directory" messages do seem like that is the problem. Could you also send the output of locale? locale

PseudoDistant avatar Apr 08 '22 22:04 PseudoDistant

These should say "ja_JP.UTF-8" instead of "ja_JP". Change it wherever you set that up initially (don't forget to log out and back in to reload the environment). That should fix it.

2xsaiko avatar Apr 09 '22 19:04 2xsaiko

These should say "ja_JP.UTF-8" instead of "ja_JP". Change it wherever you set that up initially (don't forget to log out and back in to reload the environment). That should fix it.

I set these via Plasma System Settings, I actually don't know how to change it manually.

PseudoDistant avatar Apr 16 '22 19:04 PseudoDistant

Interesting, that's probably a Plasma bug then, probably worth reporting (though for me it shows them all as having a UTF-8 suffix... not sure what's different between our installations).

Either change those back to the defaults (Reset button on the bottom panel in System Settings/Formats) and then depending on your distro, configure the system locale (see distro documentation for that, since it's specific to each one).

Otherwise, you could try setting the correct locale names in ~/.config/plasma-localerc (I assume there they don't have the UTF-8 suffix either), but I'm not sure if that will work.

2xsaiko avatar Apr 18 '22 22:04 2xsaiko