Juanjo Salvador
Juanjo Salvador

Reputation: 1093

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 scraper (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...

UPDATE

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 locales for Debian. Linux output are in japanese, but not my bot's output.

Upvotes: 5

Views: 2694

Answers (1)

Juanjo Salvador
Juanjo Salvador

Reputation: 1093

Solved using iconv for UTF-8 encode.

Upvotes: 3

Related Questions