Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If everything else fails, create a wrapper for the JVM that sets the LC_CTYPE environment variable and then launches your application. OS X doesn't care which program the plist tells it to run does it? It's probably simplest to create this wrapper in shell script:</p> <pre><code>#!/bin/bash export LC_CTYPE="UTF-8" # Try other options if this doesn't work exec java your.program.Here </code></pre> <p>The problem is with the way Java - any version of Java, from either Apple or Oracle - reads the names of files from the file system. Names of files on the file system are essentially binary data, and they must be decoded in order to use them as String in Java. (You can <a href="http://jonisalonen.com/2012/java-and-file-names-with-invalid-characters/" rel="nofollow">read more about this issue</a> in my blog.)</p> <p>The detection of the encoding varies from platform to platform and version to version, so this must be where Apple Java 6 and Oracle Java 7 differ: Java 6 detects correctly that the system is set to UTF-8, while Java 7 gets it wrong.</p> <p>Strangely though, when I try to reproduce the issue with the following program I find that both Java 6 and Java 7 <em>correctly</em> use UTF-8 to decode file names (they are printed correctly to the terminal). For other I/O, Java 6u35 is using MacRoman as the default charset, while Java 7u7 uses UTF-8 (shown by the <code>file.encoding</code> system property).</p> <pre><code>import java.io.*; public class Test { public static void main(String[] args) { System.setOut(new PrintStream(System.out, true, "UTF-8")); System.out.println(System.getProperty("file.encoding")); for (File f: new File(".").listFiles) { System.out.println(g.getName()); } } } </code></pre> <p>When I run <code>locale</code> on OS 10.7 I get this output. It seems that on my system Java 6 doesn't interpret correctly the value given for LC_CTYPE. As far as I know the system has no customizations and everything is set to English, so this should be the default configuration:</p> <pre><code>LANG= LC_COLLATE="C" LC_CTYPE="UTF-8" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL= </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload