vincexjl commented on PR #602:
URL: https://github.com/apache/commons-compress/pull/602#issuecomment-2461140127

   @garydgregory @garydgregory 
   thank your for  your reply
   Let me explain in detail my discovery process. 
   I use commons-compress version 1.21 in linux with Chninese language 
environment. The file name I am planning to compress is in Chinese, when I use 
'GzipCompressorOutputStream(final OutputStream out)' to achieve compression 
into gz. When I extracted , the file name appears as normal in Chinese, whether 
using code or tool 7-zip.
   
   but when I use 'GzipCompressorOutputStream(final OutputStream out, final 
GzipParameters parameters)' to setFilename in Chinese, the filename will become 
like ????.xml,  So I went to look through the version 1.21 source code.
   
   if (filename != null) {
               this.out.write(filename.getBytes(StandardCharsets.ISO_8859_1));
               this.out.write(0);
           }
   
   I guess that this does not support Chinese. So I modified it to  
   
   ‘this.out.write(filename.getBytes(StandardCharsets.UTF8));' to test it.  
result performs correctly on Linux in Chinese language.
   
   When I put my code on Windows in Chinese language. The file name is garbled, 
then I modified it to
   
   ‘this.out.write(filename.getBytes(Charset.forName("GBK"));' to test it.  
result performs correctly on Windows in Chinese language.
   
   I think maybe this is an unreasonable design, so I have decided to take a 
look at the latest version of the code.
   
   I find version 1.27.2-SNAPSHOT in this scenario the filename will use 
   
   'return new URI(null, null, string, 
null).toASCIIString().getBytes(StandardCharsets.US_ASCII);' to return filename。
   
   This is not consistent with the performance in the scenario of using 
'GzipCompressiorOutputStream (final OutputStream out)'.
   
   If we set a Chinese file name, the extracted name will appear incorrect.
   
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to