Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print japanese characters with node.js

Tags:

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.

like image 523
Juanjo Salvador Avatar asked Oct 19 '22 09:10

Juanjo Salvador


1 Answers

Solved using iconv for UTF-8 encode.

like image 182
Juanjo Salvador Avatar answered Nov 03 '22 06:11

Juanjo Salvador