From af5d458829fe8103ea45fcd51498140d2b7cba85 Mon Sep 17 00:00:00 2001 From: xqe2011 Date: Mon, 2 Mar 2020 09:35:35 +0800 Subject: [PATCH] Fix Bug that using not-English characters in message file will cause this topic can't received (#142) --- src/utils/tcpros_utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/tcpros_utils.js b/src/utils/tcpros_utils.js index 4c11dad..dba5de6 100644 --- a/src/utils/tcpros_utils.js +++ b/src/utils/tcpros_utils.js @@ -39,7 +39,7 @@ const tcpNoDelayField = 'tcp_nodelay=1'; function serializeStringFields(fields) { let length = 0; fields.forEach((field) => { - length += (field.length + 4); + length += (Buffer.byteLength(field) + 4); }); let buffer = new Buffer(4 + length); let offset = base_serializers.uint32(length, buffer, 0);