Juanjo Salvador Juanjo Salvador - 1 year ago 89
Node.js Question

Print japanese characters with node.js

I have a telegram bot that takes a string (japanese or spanish) and translate it using Google Translate's scrapper (this one https://github.com/statickidz/node-google-translate-free).

I tested it on Mac and works fine. But when I'm trying to deploy it on my VPS (Debian 8.3), it doesn't return japanese characters.

All I get, in Telegram and terminal, is this:


Must be a charcode failure, but it seems UTF-8 in both sides...


My code for output is this:

sakura.onText(/\/esp (.+)/, function (msg, match) {
var fromId = msg.from.id;
var input = match[1];
translate({ text: input, source: 'es', target: 'ja' }, function(result) { sakura.sendMessage(fromId, "'" + input + "', traducido, significa '" + result + "'."); });

I've tested with japanese
for Debian. Linux output are in japanese, but not my bot's output.

Answer Source

Solved using iconv for UTF-8 encode.