Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-212

TarArchiveEntry getName() returns wrongly encoded name even when you set encoding to TarArchiveInputStream

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.4.1
    • Fix Version/s: 1.5
    • Component/s: None
    • Labels:
      None
    • Environment:

      Red Hat Enterprise Linux, MS Windows 7

      Description

      I have two file systems. One is Red Hat Linux, the other is MS Windows.
      I created a *.tgz file in Red Hat Linux and tried to decompress it in MS Windows using Commons Compress.
      The default system encoding are different. UTF-8 in Red Hat Linux and CP949 in MS Windows.
      It seems that the file name encoding follows the default encoding even though when I use the following to untar it.

      FileInputStream fis = new FileInputStream(new File(*.tgz));
      TarArchiveInputStream zis = new TarArchiveInputStream(new BufferedInputStream(fis),encodingOfRedHatLinux);

      while ((entry = (TarArchiveEntry)zis.getNextEntry()) != null)
      {
      entry.getName(); // filename is not UTF-8 it is encoded in CP949 and so the filename isn't consistent
      }

      By referring to this

      /**

      • Constructor for TarInputStream.
      • @param is the input stream to use
      • @param encoding name of the encoding to use for file names
      • @since Commons Compress 1.4
        */
        public TarArchiveInputStream(InputStream is, String encoding) { this(is, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE, encoding); }

      encoding should be used for file names.
      But actually this doesn't seem to work.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              wooju.shin Woo Ju Shin
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: