2017-05-04 99 views
0
我在同時使用 utf8quoted-printable

無效的UTF-8在檢測的NodeJS

bodyHtml = utf8.decode(quotedPrintable.decode(resData['body-html'])); 

在Heroku的日誌編碼電子郵件正文的問題

,它說

2017-05-04T05:49:54.312348+00:00 app[consumerWorker.1]: 
/app/node_modules/utf8/utf8.js:194 
2017-05-04T05:49:54.312360+00:00 app[consumerWorker.1]:   throw 
Error('Invalid UTF-8 detected'); 
2017-05-04T05:49:54.312362+00:00 app[consumerWorker.1]:  ^
2017-05-04T05:49:54.312362+00:00 app[consumerWorker.1]: 
2017-05-04T05:49:54.312363+00:00 app[consumerWorker.1]: Error: Invalid 
UTF-8 detected 

我創建了一個runkit ,https://runkit.com/kiranlm/590abc3746b5b70012ffd7f8

回答

0

如果您使用的是英語utf-8: ,從終端運行

heroku config:add LANG=en_US.UTF-8 

,如果你想檢查:

$ heroku run bash 
Running bash attached to terminal... up, run.2 
[email protected]:/app$ irb 
irb(main):001:0> "a".encoding 
=> #<Encoding:UTF-8> 
+0

感謝@達米安 - lattenero,我想這一點,現在的編碼是UTF8的Heroku,但錯誤依然存在, –