-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
safari demo error (without-a-bundler-no-modules) #1825
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
Comments
Thanks for the report @cyanBone! I've updated the title of the issue here to reflect what's going on after debugging a bit. I turns out this JS snippet: (new TextDecoder('utf-8', { ignoreBOM: true })).decode(new Uint8Array([112])).charCodeAt(0) returns 65279 on Safari and 112 on Firefox. I believe the BOM is being included on the first use of @Pauan have you seen this before perchance? I figure the easiest thing to do would be to just decode something immediately to clear out the bom state on safari. |
@alexcrichton Uh, wow, that's an incredible bug in Webkit. It seems that it's always including the BOM even if the BOM doesn't exist in the I can't test Safari, but could you also try these? (new TextDecoder('utf-8', { ignoreBOM: false })).decode(new Uint8Array([])).charCodeAt(0) (new TextDecoder('utf-8', { ignoreBOM: true })).decode(new Uint8Array([])).charCodeAt(0) var decoder = new TextDecoder('utf-8', { ignoreBOM: true });
console.log(decoder.decode(new Uint8Array([112])).charCodeAt(0));
console.log(decoder.decode(new Uint8Array([112])).charCodeAt(0)); |
(new TextDecoder('utf-8', { ignoreBOM: false })).decode(new Uint8Array([])).charCodeAt(0) Prints NaN (new TextDecoder('utf-8', { ignoreBOM: true })).decode(new Uint8Array([])).charCodeAt(0) Prints 65279 var decoder = new TextDecoder('utf-8', { ignoreBOM: true });
console.log(decoder.decode(new Uint8Array([112])).charCodeAt(0));
console.log(decoder.decode(new Uint8Array([112])).charCodeAt(0)); Prints 65279 then prints 112 Ok, sounds like we should probably just decode the empty array immediately to flush the bom out of the decoder? |
Yeah, though we should have some extensive tests for this (decoding with BOM, decoding without BOM, decoding with BOM after not-BOM, etc.) |
There is also wasm in golang. I can see from its JavaScript that it can run correctly. Here I give the JavaScript in golang.this javascritp has TextDecoder |
@cyanBone Yeah, that's because they don't use |
PR up: #1829 (I'd really like some unit tests though) |
Summary
wasm-bindgen/examples/without-a-bundler-no-modules
This demo is successful in chrome, but there are errors in Safari
errors: Unhandled Promise Rejection: InvalidCharacterError: The string contains invalid characters.
Safari version 13.0.2
Additional Details
The text was updated successfully, but these errors were encountered: