From 2dca682411c1d174d97837b736242a40f08aeeb7 Mon Sep 17 00:00:00 2001 From: Kass507 Date: Thu, 24 Mar 2022 13:00:50 -0500 Subject: [PATCH] fix for special characters --- src/ue4/io/IoStore.ts | 8 ++++---- src/ue4/reader/FArchive.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ue4/io/IoStore.ts b/src/ue4/io/IoStore.ts index a4b085ac..7312c7a9 100644 --- a/src/ue4/io/IoStore.ts +++ b/src/ue4/io/IoStore.ts @@ -606,7 +606,7 @@ export class FIoStoreTocResource { for (let i = 0; i < _len1; i++) { const id = new FIoChunkId(tocBuffer) this.chunkIds[i] = id - this.chunkIdToIndex[id.id.toString("base64")] = i + this.chunkIdToIndex[id.id.toString("latin1")] = i } } @@ -637,7 +637,7 @@ export class FIoStoreTocResource { this.chunkIndicesWithoutPerfectHash[i] = tocBuffer.readInt32() } for (let chunkIndexWithoutPerfectHash of this.chunkIndicesWithoutPerfectHash) { - this.chunkIdToIndex[this.chunkIds[chunkIndexWithoutPerfectHash].id.toString("base64")] = chunkIndexWithoutPerfectHash + this.chunkIdToIndex[this.chunkIds[chunkIndexWithoutPerfectHash].id.toString("latin1")] = chunkIndexWithoutPerfectHash } } @@ -720,7 +720,7 @@ export class FIoStoreTocResource { slot = seedAsIndex } else { // Entry without perfect hash - return this.chunkIdToIndex[chunkId.id.toString("base64")] || -1 + return this.chunkIdToIndex[chunkId.id.toString("latin1")] || -1 } } else { slot = Number(chunkId.hashWithSeed(seed) % BigInt(chunkCount)) @@ -729,7 +729,7 @@ export class FIoStoreTocResource { return slot return -1 } - return this.chunkIdToIndex[chunkId.id.toString("base64")] || -1 + return this.chunkIdToIndex[chunkId.id.toString("latin1")] || -1 } /** diff --git a/src/ue4/reader/FArchive.ts b/src/ue4/reader/FArchive.ts index 6a5e67ce..b506dcc0 100644 --- a/src/ue4/reader/FArchive.ts +++ b/src/ue4/reader/FArchive.ts @@ -305,10 +305,10 @@ export abstract class FArchive { dat.push(this.readUInt16()) if (this.readUInt16() !== 0) throw new ParserException("Serialized FString is not null-terminated", this) - return Buffer.from(dat).toString("utf16le") + return Buffer.from(dat).toString("binary") } else { if (length === 0) return "" - const str = this.read(length - 1).toString("utf-8") + const str = this.read(length - 1).toString("binary") if (this.readUInt8() !== 0) throw new ParserException("Serialized FString is not null-terminated", this) return str