refactor: move text encoder/decoder to util file

This commit is contained in:
鲁树人
2023-06-17 14:28:36 +01:00
parent 761b2a4df0
commit 2881f70f68
4 changed files with 18 additions and 9 deletions

View File

@@ -1,8 +1,7 @@
import type { StagingKWMv2Key } from '~/features/settings/keyFormats';
import { bytesToUTF8String } from '~/decrypt-worker/util/utf8Encoder';
import { formatHex } from './formatHex';
const textDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
export class MMKVParser {
private offset = 4;
private length: number;
@@ -67,7 +66,7 @@ export class MMKVParser {
// ]
const strByteLen = this.readInt();
const data = this.readBytes(strByteLen);
return textDecoder.decode(data).normalize();
return bytesToUTF8String(data).normalize();
}
public readVariantString() {