mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Fixes to image serialization
This commit is contained in:
parent
6dff4e5fde
commit
1eb4ff560b
|
@ -276,11 +276,7 @@ function convertOutputMimeToJupyterOutput(mime: string, value: Uint8Array) {
|
|||
if (typeof Buffer !== 'undefined' && typeof Buffer.from === 'function') {
|
||||
return Buffer.from(value).toString('base64');
|
||||
} else {
|
||||
// https://developer.mozilla.org/en-US/docs/Glossary/Base64#solution_1_%E2%80%93_escaping_the_string_before_encoding_it
|
||||
const stringValue = textDecoder.decode(value);
|
||||
return btoa(encodeURIComponent(stringValue).replace(/%([0-9A-F]{2})/g, function (_match, p1) {
|
||||
return String.fromCharCode(Number.parseInt('0x' + p1));
|
||||
}));
|
||||
return btoa(value.reduce((s: string, b: number) => s + String.fromCharCode(b), ''));
|
||||
}
|
||||
} else if (mime.toLowerCase().includes('json')) {
|
||||
const stringValue = textDecoder.decode(value);
|
||||
|
|
Loading…
Reference in a new issue