Skip to content

Commit f553875

Browse files
committed
Merge pull request godotengine#110387 from timothyqiu/project-zip-utf8
Set language encoding flag when using Pack Project as ZIP
2 parents 7ec4bd7 + cadd08d commit f553875

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

editor/export/project_zip_packer.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ void ProjectZIPPacker::_zip_file(const String &p_path, const String &p_base_path
7272
data.resize(len);
7373
f->get_buffer(data.ptrw(), len);
7474

75-
String path = p_path.replace_first(p_base_path, "");
76-
zipOpenNewFileInZip(p_zip,
75+
String path = p_path.trim_prefix(p_base_path);
76+
zipOpenNewFileInZip4(p_zip,
7777
path.utf8().get_data(),
7878
nullptr,
7979
nullptr,
@@ -82,7 +82,15 @@ void ProjectZIPPacker::_zip_file(const String &p_path, const String &p_base_path
8282
0,
8383
nullptr,
8484
Z_DEFLATED,
85-
Z_DEFAULT_COMPRESSION);
85+
Z_DEFAULT_COMPRESSION,
86+
0,
87+
-MAX_WBITS,
88+
DEF_MEM_LEVEL,
89+
Z_DEFAULT_STRATEGY,
90+
nullptr,
91+
0,
92+
0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions
93+
1 << 11); // Bit 11 is the language encoding flag. When set, filename and comment fields must be encoded using UTF-8.
8694
zipWriteInFileInZip(p_zip, data.ptr(), data.size());
8795
zipCloseFileInZip(p_zip);
8896
}
@@ -101,8 +109,8 @@ void ProjectZIPPacker::_zip_recursive(const String &p_path, const String &p_base
101109
if (cur == "." || cur == ".." || cur == project_data_dir_name) {
102110
// Skip
103111
} else if (dir->current_is_dir()) {
104-
String path = cs.replace_first(p_base_path, "") + "/";
105-
zipOpenNewFileInZip(p_zip,
112+
String path = cs.trim_prefix(p_base_path) + "/";
113+
zipOpenNewFileInZip4(p_zip,
106114
path.utf8().get_data(),
107115
nullptr,
108116
nullptr,
@@ -111,7 +119,15 @@ void ProjectZIPPacker::_zip_recursive(const String &p_path, const String &p_base
111119
0,
112120
nullptr,
113121
Z_DEFLATED,
114-
Z_DEFAULT_COMPRESSION);
122+
Z_DEFAULT_COMPRESSION,
123+
0,
124+
-MAX_WBITS,
125+
DEF_MEM_LEVEL,
126+
Z_DEFAULT_STRATEGY,
127+
nullptr,
128+
0,
129+
0x0314, // "version made by", 0x03 - Unix, 0x14 - ZIP specification version 2.0, required to store Unix file permissions
130+
1 << 11); // Bit 11 is the language encoding flag. When set, filename and comment fields must be encoded using UTF-8.
115131
zipCloseFileInZip(p_zip);
116132
_zip_recursive(cs, p_base_path, p_zip);
117133
} else {

0 commit comments

Comments
 (0)