2023-02-13 08:52:44 +00:00
|
|
|
/*
|
|
|
|
* @Author: Kane
|
|
|
|
* @Date: 2023-02-13 14:54:46
|
|
|
|
* @LastEditors: Kane
|
|
|
|
* @LastEditTime: 2023-02-13 14:55:19
|
|
|
|
* @FilePath: /pako/src/utils/StringConverter.js
|
|
|
|
* @Description:
|
|
|
|
*
|
|
|
|
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
|
|
|
*/
|
|
|
|
function Uint8ArrayToString(fileData) {
|
2023-02-13 16:23:26 +00:00
|
|
|
let dataString = "";
|
|
|
|
for (let i = 0; i < fileData.length; i++) {
|
2023-02-13 08:52:44 +00:00
|
|
|
dataString += String.fromCharCode(fileData[i]);
|
|
|
|
}
|
|
|
|
return dataString;
|
|
|
|
}
|
|
|
|
function stringToUint8Array(str) {
|
2023-02-13 16:23:26 +00:00
|
|
|
const arr = [];
|
|
|
|
for (let i = 0, j = str.length; i < j; ++i) {
|
2023-02-13 08:52:44 +00:00
|
|
|
arr.push(str.charCodeAt(i));
|
|
|
|
}
|
2023-02-13 16:23:26 +00:00
|
|
|
const tmpUint8Array = new Uint8Array(arr);
|
2023-02-13 08:52:44 +00:00
|
|
|
return tmpUint8Array;
|
|
|
|
}
|
2023-02-13 16:23:26 +00:00
|
|
|
export { Uint8ArrayToString, stringToUint8Array };
|
2023-02-13 08:52:44 +00:00
|
|
|
//# sourceMappingURL=StringConvert.js.map
|