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

More information about text encoding when creating a Blob #25282

Closed
domleonard opened this issue Mar 13, 2023 · 1 comment · Fixed by #27735
Closed

More information about text encoding when creating a Blob #25282

domleonard opened this issue Mar 13, 2023 · 1 comment · Fixed by #27735
Assignees
Labels
area: File/File System Content:WebAPI Web API docs good first issue A good issue for newcomers to get started with.

Comments

@domleonard
Copy link
Contributor

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob

What specific section or headline is this issue about?

The note about strings under description of the array parameter

What information was incorrect, unhelpful, or incomplete?

The note for strings under the array parameter description states

Note that strings here are encoded as UTF-8, unlike the usual JavaScript UTF-16 strings.

This can be confusing and could be interpreted as meaning strings provided should be encoded in utf8 already and that standard JavaScript strings are not acceptable.

What did you expect to see?

Possibly a note worded more along the lines of

Note that string items in array are treated as Unicode text and serialized in Blob output using utf8 encoding. In particular, providing base64 or binary string values in array never converts them to binary data when a Blob is serialized.

Do you have any supporting links, references, or citations?

processing Blob Parts under Contructor parameters in the FIle API standard.

USVString in the Web IDL standard.

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@domleonard domleonard added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Mar 13, 2023
@github-actions github-actions bot added the Content:WebAPI Web API docs label Mar 13, 2023
@Josh-Cena
Copy link
Member

It means strings have to be well-formed Unicode strings (USVString), without lone surrogates. It has nothing to do with UTF-8, as far as I'm concerned. Lone surrogates are replaced with U+FFFD (see toWellFormed()). We should change

Note that strings here are encoded as UTF-8, unlike the usual JavaScript UTF-16 strings.

to

Strings should be well-formed Unicode, and lone surrogates are sanitized using the same algorithm as {{jsxref("String.prototype.toWellFormed()")}}.

@Josh-Cena Josh-Cena added good first issue A good issue for newcomers to get started with. and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels May 31, 2023
@sideshowbarker sideshowbarker self-assigned this Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: File/File System Content:WebAPI Web API docs good first issue A good issue for newcomers to get started with.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants