From 8e21b8467e7e312b6c8f5e2b25fece934b6f3d5f Mon Sep 17 00:00:00 2001 From: Jonathan Underwood Date: Wed, 3 Mar 2021 21:29:22 +0900 Subject: [PATCH] Decode hex into utf8 instead of ascii --- frontend/src/app/shared/pipes/hex2ascii/hex2ascii.pipe.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/shared/pipes/hex2ascii/hex2ascii.pipe.ts b/frontend/src/app/shared/pipes/hex2ascii/hex2ascii.pipe.ts index caf81dd82..3d62ae7d6 100644 --- a/frontend/src/app/shared/pipes/hex2ascii/hex2ascii.pipe.ts +++ b/frontend/src/app/shared/pipes/hex2ascii/hex2ascii.pipe.ts @@ -15,11 +15,11 @@ export class Hex2asciiPipe implements PipeTransform { if (!hex) { return ''; } - let str = ''; + let bytes: number[] = []; for (let i = 0; i < hex.length; i += 2) { - str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); + bytes.push(parseInt(hex.substr(i, 2), 16)); } - return str; + return new TextDecoder('utf8').decode(Uint8Array.from(bytes)); } }