Info about Blob blobParts strings encoding#44324
Conversation
|
Preview URLs (1 page) External URLs (1)URL:
|
pepelsbey
left a comment
There was a problem hiding this comment.
Hey! Thank you for the PR.
Could you please clarify what issue this PR addresses?
It might look self-evident to you, but it would be good to understand intention. We don’t bring everything from the spec to MDN. Only the parts that are useful for web developers.
|
@pepelsbey --- Well recently, I was working with strings and Blobs, and wondered what the character encoding was, this information is vital when decoding. Decoding using the wrong character encoding produces something totally different from the original text. const bytes = await new Blob(["this is a UTF-16 string that will be converted to UTF-8"]).bytes();
console.log(new TextDecoder("UTF-8").decode(bytes)); // this is a UTF-16 string that will be converted to UTF-8
console.log(new TextDecoder("UTF-16").decode(bytes)); // 桴獩椠呕ⵆ㘱猠牴湩桴瑡眠汩敢挠湯敶瑲摥琠呕ⵆ� |
pepelsbey
left a comment
There was a problem hiding this comment.
I would suggest keeping it simpler: UTF-16 is an implementation detail that developers don’t ever encounter. And linking to the spec is not required, it’s enough to say how things are. What do you think?
No description provided.