I did some more investigation on the issue. Sharing some findings and thoughts.
Reading a preference is done in two steps.
- First, the java preference string is read from the .java/.userPrefs/defold/prefs.xml file. As a string.
- The string is parsed and assumed to contain something in json.
I logged the offending preference (containing greek/UTF8 chars) after step 1 but before step2.
FETHED PREFERENCE key open-project-directory and value ["~#'","/home/nando/τεστ2"]
2021-01-19 01:12:37.276 ERROR default editor.prefs - {:line 67, :msg "failed to fetch preference for open-project-directory with value [\"~#'\",\"/home/nando/τεστ2\"]"}
java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0xc4
So, from the first line it seems that the greek characters are loaded ok. The error occurs afterwards at step 2, when reading the string and try to decode it as json. But why deal with UTF-8 at this later stage though? The string is already loaded and displayed correctly and i guess it should now be in java's internal format (utf16 or something like that).
Digging further, the offending clojure block that will try to read from the pref string and parse into json is this:
(defn- read-transit [s]
(let [reader (transit/reader (StringBufferInputStream. s) :json {:handlers read-handlers})]
(transit/read reader)))
(https://github.com/defold/defold/blob/dev/editor/src/clj/editor/prefs.clj#L39)
IntelliJ reports StringBufferInputStream as Deprecated. And javadoc says the same:
https://docs.oracle.com/javase/7/docs/api/java/io/StringBufferInputStream.html
I'm wondering if this bug is about that i.e. StringBufferInputStream being unable to properly handle such characters right.
I'll try to replace it with something else and see if this makes things any better.