Correctly handle filename encoding #358

Merged
jwharm merged 1 commit from filenames into main 2026-05-05 21:34:21 +02:00
Owner

GLib supports filesystems with encodings other than UTF8. These paths and filenames are annotated as "filename". Up until now, Java-GI treated them as ordinary UTF8 strings, which will not work on non-UTF8 encoded filesystems where the filename has special characters. This is now correctly implemented: Java-GI has a class org.javagi.base.Filename that stores the filename as a raw byte[], and can be converted to and from Strings using the appropriate conversion functions from GLib.

Consult the GLib documentation at https://docs.gtk.org/glib/character-set.html for more information about the use case for this.

To minimize the impact on Java developers, all Java methods with Filename parameters that Java-GI generates, are overloaded with a String parameter. As a result, a Java developer can choose to pass a Filename or a regular String, depending on the situation. This also ensures backwards compatibility for most code that was written for earlier versions of Java-GI.

GLib supports filesystems with encodings other than UTF8. These paths and filenames are annotated as "filename". Up until now, Java-GI treated them as ordinary UTF8 strings, which will not work on non-UTF8 encoded filesystems where the filename has special characters. This is now correctly implemented: Java-GI has a class `org.javagi.base.Filename` that stores the filename as a raw `byte[]`, and can be converted to and from Strings using the appropriate conversion functions from GLib. Consult the GLib documentation at https://docs.gtk.org/glib/character-set.html for more information about the use case for this. To minimize the impact on Java developers, all Java methods with Filename parameters that Java-GI generates, are overloaded with a String parameter. As a result, a Java developer can choose to pass a Filename or a regular String, depending on the situation. This also ensures backwards compatibility for most code that was written for earlier versions of Java-GI.
jwharm merged commit 363d21da53 into main 2026-05-05 21:34:21 +02:00
jwharm deleted branch filenames 2026-05-05 21:34:28 +02:00
Sign in to join this conversation.
No description provided.