From 45dc8f81c9579a8e538791d96550dc752d7e30c6 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Mon, 2 Aug 2021 10:36:50 +1000 Subject: [PATCH] Fixed `ChatMessage.payloadAsUtf8` returning garbage on utf-8 non-ascii --- CHANGELOG.md | 1 + src/lib/chat_message/index.ts | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22962ff584..312af25841 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - `WakuMessage.payloadAsUtf8` returning garbage on utf-8 non-ascii characters. +- `ChatMessage.payloadAsUtf8` returning garbage on utf-8 non-ascii characters. ## [0.9.0] - 2021-07-26 diff --git a/src/lib/chat_message/index.ts b/src/lib/chat_message/index.ts index 04e3389d17..2ebceb1f68 100644 --- a/src/lib/chat_message/index.ts +++ b/src/lib/chat_message/index.ts @@ -60,10 +60,6 @@ export class ChatMessage { return ''; } - return Array.from(this.proto.payload) - .map((char) => { - return String.fromCharCode(char); - }) - .join(''); + return Buffer.from(this.proto.payload).toString('utf-8'); } }