Skip to content

Update ZipArchive.xml, ZipFile.xml #10193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
If the `mode` parameter is set to <xref:System.IO.Compression.ZipArchiveMode.Read>, the stream must support reading. If the `mode` parameter is set to <xref:System.IO.Compression.ZipArchiveMode.Create>, the stream must support writing. If the `mode` parameter is set to <xref:System.IO.Compression.ZipArchiveMode.Update>, the stream must support reading, writing, and seeking.

When you open a zip archive file for reading and `entryNameEncoding` is set to `null`, entry names are decoded according to the following rules:
When you open a zip archive file for reading and `entryNameEncoding` is set to `null`, entry names and comments are decoded according to the following rules:

- When the language encoding flag (in the general-purpose bit flag of the local file header) is not set, the current system default code page is used to decode the entry name.
- When the language encoding flag (in the general-purpose bit flag of the local file header) is not set, the current system default code page is used to decode the entry name and comment.

- When the language encoding flag is set, UTF-8 is used to decode the entry name.
- When the language encoding flag is set, UTF-8 is used to decode the entry name and comment.

When you open a zip archive file for reading and `entryNameEncoding` is set to a value other than `null`, entry names are decoded according to the following rules:
When you open a zip archive file for reading and `entryNameEncoding` is set to a value other than `null`, entry names and comments are decoded according to the following rules:

- When the language encoding flag is not set, the specified `entryNameEncoding` is used to decode the entry name.
- When the language encoding flag is not set, the specified `entryNameEncoding` is used to decode the entry name and comment.

- When the language encoding flag is set, UTF-8 is used to decode the entry name.
- When the language encoding flag is set, UTF-8 is used to decode the entry name and comment.

When you write to archive files and `entryNameEncoding` is set to `null`, entry names are encoded according to the following rules:
When you write to archive files and `entryNameEncoding` is set to `null`, entry names and comments are encoded according to the following rules:

- For entry names that contain characters outside the ASCII range, the language encoding flag is set, and entry names are encoded by using UTF-8.
- For entry names and comments that contain characters outside the ASCII range, the language encoding flag is set, and entry names and comments are encoded by using UTF-8.

- For entry names that contain only ASCII characters, the language encoding flag is not set, and entry names are encoded by using the current system default code page.
- For entry names and comments that contain only ASCII characters, the language encoding flag is not set, and entry names and comments are encoded by using the current system default code page.

When you write to archive files and `entryNameEncoding` is set to a value other than `null`, the specified `entryNameEncoding` is used to encode the entry names into bytes. The language encoding flag (in the general-purpose bit flag of the local file header) is set only when the specified encoding is a UTF-8 encoding.
When you write to archive files and `entryNameEncoding` is set to a value other than `null`, the specified `entryNameEncoding` is used to encode the entry names and comments into bytes. The language encoding flag (in the general-purpose bit flag of the local file header) is set only when the specified encoding is a UTF-8 encoding.
20 changes: 10 additions & 10 deletions includes/remarks/System.IO.Compression/ZipFile/Open.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ When you set the `mode` parameter to <xref:System.IO.Compression.ZipArchiveMode.

When you set the `mode` parameter to <xref:System.IO.Compression.ZipArchiveMode.Update>, the archive is opened with <xref:System.IO.FileMode.OpenOrCreate?displayProperty=nameWithType> as the file mode value. If the archive exists, it is opened. The existing entries can be modified and new entries can be created. If the archive does not exist, a new archive is created; however, creating a zip archive in <xref:System.IO.Compression.ZipArchiveMode.Update> mode is not as efficient as creating it in <xref:System.IO.Compression.ZipArchiveMode.Create> mode.

When you open a zip archive file for reading and `entryNameEncoding` is set to `null`, entry names are decoded according to the following rules:
When you open a zip archive file for reading and `entryNameEncoding` is set to `null`, entry names and comments are decoded according to the following rules:

- When the language encoding flag (in the general-purpose bit flag of the local file header) is not set, the current system default code page is used to decode the entry name.
- When the language encoding flag (in the general-purpose bit flag of the local file header) is not set, the current system default code page is used to decode the entry name and comment.

- When the language encoding flag is set, UTF-8 is used to decode the entry name.
- When the language encoding flag is set, UTF-8 is used to decode the entry name and comment.

When you open a zip archive file for reading and `entryNameEncoding` is set to a value other than `null`, entry names are decoded according to the following rules:
When you open a zip archive file for reading and `entryNameEncoding` is set to a value other than `null`, entry names and comments are decoded according to the following rules:

- When the language encoding flag is not set, the specified `entryNameEncoding` is used to decode the entry name.
- When the language encoding flag is not set, the specified `entryNameEncoding` is used to decode the entry name and comment.

- When the language encoding flag is set, UTF-8 is used to decode the entry name.
- When the language encoding flag is set, UTF-8 is used to decode the entry name and comment.

When you write to archive files and `entryNameEncoding` is set to `null`, entry names are encoded according to the following rules:
When you write to archive files and `entryNameEncoding` is set to `null`, entry names and comments are encoded according to the following rules:

- For entry names that contain characters outside the ASCII range, the language encoding flag is set, and entry names are encoded by using UTF-8.
- For entry names or comments that contain characters outside the ASCII range, the language encoding flag is set, and entry names and comments are encoded by using UTF-8.

- For entry names that contain only ASCII characters, the language encoding flag is not set, and entry names are encoded by using the current system default code page.
- For entry names or comments that contain only ASCII characters, the language encoding flag is not set, and entry names and comments are encoded by using the current system default code page.

When you write to archive files and `entryNameEncoding` is set to a value other than `null`, the specified `entryNameEncoding` is used to encode the entry names into bytes. The language encoding flag (in the general-purpose bit flag of the local file header) is set only when the specified encoding is a UTF-8 encoding.
When you write to archive files and `entryNameEncoding` is set to a value other than `null`, the specified `entryNameEncoding` is used to encode the entry names and comments into bytes. The language encoding flag (in the general-purpose bit flag of the local file header) is set only when the specified encoding is a UTF-8 encoding.
2 changes: 1 addition & 1 deletion xml/System.IO.Compression/ZipArchive.xml
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
<param name="mode">One of the enumeration values that indicates whether the zip archive is used to read, create, or update entries.</param>
<param name="leaveOpen">
<see langword="true" /> to leave the stream open after the <see cref="T:System.IO.Compression.ZipArchive" /> object is disposed; otherwise, <see langword="false" />.</param>
<param name="entryNameEncoding">The encoding to use when reading or writing entry names in this archive. Specify a value for this parameter only when an encoding is required for interoperability with zip archive tools and libraries that do not support UTF-8 encoding for entry names.</param>
<param name="entryNameEncoding">The encoding to use when reading or writing entry names and comments in this archive. Specify a value for this parameter only when an encoding is required for interoperability with zip archive tools and libraries that do not support UTF-8 encoding for entry names or comments.</param>
<summary>Initializes a new instance of the <see cref="T:System.IO.Compression.ZipArchive" /> class on the specified stream for the specified mode, uses the specified encoding for entry names, and optionally leaves the stream open.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
Expand Down
Loading