Hopefully this is worthwhile to someone, but to continue an earlier post....
I encountered an issue on Windows wherein loading UTF-8 fileNames from a UTF-8 MySql database would not always work.
I saw that Charset.defaultCharset().name = "windows-1252", so I thought converting the string to UTF-8 would work.
Though this worked for some fileNames, I've discovered that it doesn't work for others.
The problem seems to be the .getBytes() call. I think JNA is using .getBytes() which will return *wrong* values for windows-1252, but *right* values for UTF-8
Note that .charAt works correctly in both defaultCharsets, as they always return the same value in both windows-1252 and UTF-8.
For example, I'm using a Japanese character (I have no idea what it is)
When Charset.defaultCharset().name = "UTF-8", I get
.charAt(0) 20304
.getBytes[0] -28
.getBytes[1] -67
-28, -67 is the correct DBCS (and how the file is named on my drive). vlcj does find the file
When Charset.defaultCharset().name = "windows-1252", I get
.charAt(0) 20304
.getBytes[0] 63
63 is obviously ? and vlcj will not find the file
I'm still relatively new to Java, so I don't know if there is a real way to re-encode a windows-1252 string as UTF-8 such that a getBytes() works. From what I've read, there is no programmatic way. My earlier example definitely does not work.
What does seem to work is to set the jvm encoding at startup.
Code: Select all
java -jar myjar.jar -Dfile.encoding=UTF-8
So far this works for all files I've encountered. However, I am seeing the following errors outputted to my console.
libdvdread: Using libdvdcss version 1.2.10 for DVD access
libdvdread: Could not open C:\folder\?????.flac with libdvdcss.
libdvdread: Can't open C:\folder\?????.flac for reading
vlc continues fine though, and as I said, the file does play. Stability is fine as well.
Does anyone have any idea about the error messages? I've also seen variants of these messages crop up randomly when calling .playMedia