upstash / qstash-js

Message queue for serverless
https://docs.upstash.com/qstash
MIT License
133 stars 11 forks source link

qstash Chinese garbled code #88

Closed huoyingjianshen closed 1 month ago

huoyingjianshen commented 2 months ago

When there is Chinese characters in the message, the result returned by base64 encryption is garbled:

"### 视频标题:小猫的滑板日记:毛茸茸的初学者大冒险\n\n#### 引入:\n- 开场画面:慢动作镜头,å".

fahreddinozcan commented 1 month ago

Hey, can you provide more details about the issue? How can we reproduce this issue?

sancar commented 1 month ago

We gave support to this on company support channel but let me share my answer here so that others can benefit as well.

Hi, It looks like qstash works as expected but you need to do some extra hacks on the receiving side. ​ I have found the solution here. ​https://base64.guru/developers/javascript/examples/unicode-strings ​ I have tried returning "chinese华语" from the endpoint and receiving it from the callback. ​ The callback receives body as "Y2hpbmVzZeWNjuivrQ==" ​ If you try to do atob("Y2hpbmVzZeWNjuivrQ==") the response is wrong as you said. ​ But if you follow the suggestion that I have found as follows: ​ decodeURIComponent(escape(atob("Y2hpbmVzZeWNjuivrQ==")));

It returns back the original body 'chinese华语' ​ Closing this issue for now. New readers of the issue or @huoyingjianshen is welcome to reopen an issue if this is not enough. ​