Skip to content
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

compress/gzip: NewWriter doc clarity #12361

Closed
bradfitz opened this issue Aug 27, 2015 · 4 comments
Closed

compress/gzip: NewWriter doc clarity #12361

bradfitz opened this issue Aug 27, 2015 · 4 comments

Comments

@bradfitz
Copy link
Contributor

The docs for gzip.NewWriter include:

The Comment and Name header fields are UTF-8 strings in Go, but the underlying format requires NUL-terminated ISO 8859-1 (Latin-1). NUL or non-Latin-1 runes in those strings will lead to an error on Write.

But I'm not exactly sure what it's trying to say.

/cc @nigeltao @mdempsky @adg @dsymonds (not sure who owns this)

@bradfitz bradfitz added this to the Go1.6 milestone Aug 27, 2015
@minux
Copy link
Member

minux commented Aug 27, 2015 via email

@mdempsky
Copy link
Member

I've never seen that comment before, and I agree it seems somewhat out of place at first impression. Here's my understanding:

  1. It's talking about the Comment and Name fields in gzip.Header.
  2. Those fields are Go strings.
  3. Canonically, Go strings are UTF-8, so they can represent any sequence of Unicode characters (including embedded NULs).
  4. However, the underlying gzip file format only allows Comment and Name to contain the Unicode characters U+0001 through U+00FF (because it's actually Latin-1 with a NUL terminator).
  5. If the Comment or Name fields contain other characters, then gzip.(*Writer).Write will return an error.

@bradfitz
Copy link
Contributor Author

@minux, yes, it's probably time for something like that.

@gopherbot
Copy link

CL https://golang.org/cl/13939 mentions this issue.

@golang golang locked and limited conversation to collaborators Sep 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants