Fabio Zadrozny created JRUBY-6664: ------------------------------------- Summary: Ruby does not deal with filesystem unicode chars properly Key: JRUBY-6664 URL: https://jira.codehaus.org/browse/JRUBY-6664 Project: JRuby Issue Type: Bug Components: Encoding Affects Versions: JRuby 1.6.4 Environment: Windows 7 Reporter: Fabio Zadrozny
I.e.: the code: org.jruby.RubyFileTest.directory_p(ThreadContext, IRubyObject), which does: runtime.getPosix().stat(file.getAbsolutePath()).isDirectory() "No such file or directory" error is thrown. Internally it does something as LibC.stat(path, fileStat), and apparently the problem is that the LibC.stat is not converting the java string to the filesystem encoding properly (note: my guess is that in windows it needs to be converted to the mbcs encoding, while in Linux the string can probably be used as is because it's an utf-8 string). The code below reproduces the error in the same way that org.jruby.RubyFileTest.directory_p(ThreadContext, IRubyObject) does (but in a proper test-case). {code} import java.io.File; import junit.framework.TestCase; import org.jruby.Ruby; import org.jruby.RubyFile; import org.jruby.RubyString; import org.jruby.util.JRubyFile; /** * @author Fabio */ public class UnicodeCharsJRubyTest extends TestCase { public void testUnicodeChars() throws Exception { File file = new File("unicodeáéíóú"); if (file.exists()) { if (!file.delete()) { fail("Unable to delete file: " + file); } } try { if (!file.mkdirs()) { fail("Unable to create directory: " + file); } Ruby runtime = Ruby.newInstance(); JRubyFile rubyFile = RubyFile.file(RubyString.newString(runtime, file.getAbsolutePath())); assertTrue(rubyFile.exists()); assertTrue(file.exists()); assertTrue(file.isDirectory()); try { assertTrue(runtime.getPosix().stat(rubyFile.getAbsolutePath()).isDirectory()); } catch (Exception e) { throw new RuntimeException("Expecting posix layer to work properly", e); } } finally { if (file.exists()) { file.delete(); } } } } {code} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email