Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-4794

[classlib][luni] unable to create file with Asian characters in name

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • WinXP

    Description

      Looks like Harmony is unable to create file if its name contains non-ASCII characters. Please see the test case below.

      TestAsianFileName.java

      import java.io.File;
      import java.io.FileInputStream;
      import java.io.FileOutputStream;

      public class TestAsianFileName {
      static final String FILENAME="\u30d5\u30a1\u30a4\u30eb1.txt";

      public static void main(String argv[]) throws Exception {
      final String CONTENT = "A pretty predicament";
      final String CNTNT_CHARSET = "ISO-8859-1";

      File f = new File(FILENAME);
      FileOutputStream fos = new FileOutputStream(f);
      FileInputStream fis;

      f.createNewFile();
      fos.write(CONTENT.getBytes(CNTNT_CHARSET));
      fos.close();

      if (f.exists()) {
      byte tmp[] = new byte[256];
      String wasRed;
      int n;

      fis = new FileInputStream(f);
      n = fis.read(tmp);
      wasRed = new String(tmp, 0, n, CNTNT_CHARSET);
      if (!CONTENT.equals(wasRed))

      { System.out.println("FAIL: invalid content was red"); return; }

      } else

      { System.out.println("FAIL: file does not exist"); return; }

      System.out.println("PASS");
      }

      }

      Attachments

        1. H4794.patch
          12 kB
          Alexei Zakharov

        Issue Links

          Activity

            People

              zakha Alexei Zakharov
              zakha Alexei Zakharov
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: