From cadd08da9e62ff1729dac17ca319d10732f06a82 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Wed, 10 Sep 2025 21:00:15 +0800 Subject: [PATCH] Set language encoding flag when using Pack Project as ZIP --- editor/export/project_zip_packer.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/editor/export/project_zip_packer.cpp b/editor/export/project_zip_packer.cpp index f5d978a1012..4e4639b1074 100644 --- a/editor/export/project_zip_packer.cpp +++ b/editor/export/project_zip_packer.cpp @@ -72,8 +72,8 @@ void ProjectZIPPacker::_zip_file(const String &p_path, const String &p_base_path data.resize(len); f->get_buffer(data.ptrw(), len); - String path = p_path.replace_first(p_base_path, ""); - zipOpenNewFileInZip(p_zip, + String path = p_path.trim_prefix(p_base_path); + zipOpenNewFileInZip4(p_zip, path.utf8().get_data(), nullptr, nullptr, @@ -82,7 +82,15 @@ void ProjectZIPPacker::_zip_file(const String &p_path, const String &p_base_path 0, nullptr, Z_DEFLATED, - Z_DEFAULT_COMPRESSION); + Z_DEFAULT_COMPRESSION, + 0, + -MAX_WBITS, + DEF_MEM_LEVEL, + Z_DEFAULT_STRATEGY, + nullptr, + 0, + 0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions + 1 << 11); // Bit 11 is the language encoding flag. When set, filename and comment fields must be encoded using UTF-8. zipWriteInFileInZip(p_zip, data.ptr(), data.size()); zipCloseFileInZip(p_zip); } @@ -101,8 +109,8 @@ void ProjectZIPPacker::_zip_recursive(const String &p_path, const String &p_base if (cur == "." || cur == ".." || cur == project_data_dir_name) { // Skip } else if (dir->current_is_dir()) { - String path = cs.replace_first(p_base_path, "") + "/"; - zipOpenNewFileInZip(p_zip, + String path = cs.trim_prefix(p_base_path) + "/"; + zipOpenNewFileInZip4(p_zip, path.utf8().get_data(), nullptr, nullptr, @@ -111,7 +119,15 @@ void ProjectZIPPacker::_zip_recursive(const String &p_path, const String &p_base 0, nullptr, Z_DEFLATED, - Z_DEFAULT_COMPRESSION); + Z_DEFAULT_COMPRESSION, + 0, + -MAX_WBITS, + DEF_MEM_LEVEL, + Z_DEFAULT_STRATEGY, + nullptr, + 0, + 0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions + 1 << 11); // Bit 11 is the language encoding flag. When set, filename and comment fields must be encoded using UTF-8. zipCloseFileInZip(p_zip); _zip_recursive(cs, p_base_path, p_zip); } else {