提交 d37368ec 编写于 作者: L Lianjy

[*]zip脚本上传window中文乱码兼容

上级 a360bb89
package org.ssssssss.magicapi.core.resource;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
import java.util.Map;
......@@ -36,7 +38,8 @@ public class ZipResource implements Resource {
while ((len = zis.read(buf, 0, buf.length)) != -1) {
os.write(buf, 0, len);
}
cachedContent.put(entry.getName(), os.toByteArray());
String charset = ((ZipArchiveEntry) entry).getGeneralPurposeBit().usesUTF8ForNames() ? StandardCharsets.UTF_8.name() : "GBK";
cachedContent.put(new String(((ZipArchiveEntry) entry).getRawName(), charset), os.toByteArray());
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册