microgateway icon indicating copy to clipboard operation
microgateway copied to clipboard

utf-8 string length for invoke

Open king729 opened this issue 7 years ago • 2 comments

when i use chinese utf8 i get the wrong size convert string to buffer

king729 avatar Jan 10 '18 08:01 king729

Can you say a little more about the use case and symptoms of the issue? Since new Buffer is deprecated it would be better to use Buffer.from.

tonyffrench avatar Jan 25 '18 16:01 tonyffrench

@tonyffrench When the json payload contains non-ascii characters, the calculated length of the payload is wrong. It counts the number of characters instead of the number of bytes. The result is that the last characters of the payload are truncated, meaning invalid JSON. This is an important fix. I had the issue with accented latin characters.

mathieudz avatar Nov 15 '18 12:11 mathieudz