Skip to content

Commit

Permalink
[fix] Change Uint16Array to Uint8Array in stringToArrayBuffer method (#…
Browse files Browse the repository at this point in the history
…1756)

* [fix] Change Uint16Array to Uint8Array in stringToArrayBuffer method
  • Loading branch information
VkoHov authored May 17, 2022
1 parent b0a4f9a commit 5b88767
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aim/web/ui/src/services/live-update/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function createGetStream(
* @returns String.
*/
function arrayBufferToString(buffer: ArrayBuffer): string {
return String.fromCharCode.apply(null, Array.from(new Uint16Array(buffer)));
return String.fromCharCode.apply(null, Array.from(new Uint8Array(buffer)));
}

/**
Expand All @@ -69,12 +69,12 @@ function arrayBufferToString(buffer: ArrayBuffer): string {
*/
function stringToArrayBuffer(str: string): ArrayBuffer {
const stringLength = str.length;
const buffer = new ArrayBuffer(stringLength * 2);
const bufferView = new Uint16Array(buffer);
const buffer = new ArrayBuffer(stringLength);
const bufferView = new Uint8Array(buffer);
for (let i = 0; i < stringLength; i++) {
bufferView[i] = str.charCodeAt(i);
}
return buffer;
return bufferView;
}

/**
Expand Down

0 comments on commit 5b88767

Please sign in to comment.