From 4d3666d4c756e05287560ab1f0c77d03c751e8d8 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Thu, 5 Jul 2018 15:54:14 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Use=20UTF-16LE=20encoding=20for?= =?UTF-8?q?=20manifest=20XML=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssn/getManifest.ts | 2 +- src/ssn/streams/streamToString.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ssn/getManifest.ts b/src/ssn/getManifest.ts index e0e1abb..df5b3b2 100644 --- a/src/ssn/getManifest.ts +++ b/src/ssn/getManifest.ts @@ -38,7 +38,7 @@ export default async function getManifest(product: Product): Promise const patchmanifestStream = extractFileStream(firstFile, stream); //Convert ArrayBuffer to string - const patchmanifestXml = await streamToString(patchmanifestStream); + const patchmanifestXml = await streamToString(patchmanifestStream, 'utf-16le'); //convert XML to JSON-converted XML const patchManifestJson = xmlJs.xml2js(patchmanifestXml) as xmlJs.Element; diff --git a/src/ssn/streams/streamToString.ts b/src/ssn/streams/streamToString.ts index 97cf953..1260e35 100644 --- a/src/ssn/streams/streamToString.ts +++ b/src/ssn/streams/streamToString.ts @@ -1,8 +1,8 @@ import * as stream from 'stream'; import { TextDecoder } from 'util'; -export default function streamToString(inputStream: stream.Readable): Promise { - const decoder = new TextDecoder('utf-8'); +export default function streamToString(inputStream: stream.Readable, encoding: string = 'utf-8'): Promise { + const decoder = new TextDecoder(encoding); //utf-8 or utf-16le return new Promise((resolve, reject) => { const stringParts: string[] = [];