0

I am developing a chrome extension with nodejs. I used robotjs module to write some text in an input tag. It writes English characters well but when I want to write persian characters, it shows special character for each character in my string in the nodemon console (when I try console.log()), and wrong characters in the input tag. here is part of my robot.js that implements write string methods.

robot.moveMouseSmooth(280, 280); // it moves mouse pointer to the input field
robot.mouseClick(); // one click on the field
robot.typeString("سارا"); //types the string that I want

The output in the input tag is:

31

I also tried this: buf = iconv.encode("سارا", 'win1256'); encoding. it shows buffer value of my string and also is not true answer. when I try to log buf in nodemon console, it's output is:

<Buffer 3f d3 c7 d1 c7>

base on this link , robotjs module supports Unicode since v0.5.0

MeirDayan
  • 620
  • 5
  • 20
  • What are you running the script at? Windows cmd.exe? – Tomalak Sep 06 '20 at 11:18
  • It is cmd for running nodemon. @Tomalak – MeirDayan Sep 06 '20 at 11:19
  • when you create a text file in Notepad.exe that contains `سارا`, and then call `type file.txt` in cmd.exe, do the characters appear correctly on the console? – Tomalak Sep 06 '20 at 11:22
  • No. for English characters it is correct but it is wrong (special character) for persian. @Tomalak – MeirDayan Sep 06 '20 at 11:31
  • So if you think about it, this is not a node.js problem, but a cmd.exe problem, right? – Tomalak Sep 06 '20 at 11:34
  • Writing correct text in cmd is not the thing I want. I want to write it correct in the input tag in html. Are these related?@Tomalak – MeirDayan Sep 06 '20 at 11:37
  • I understood that you look at the output of your program on the console and are not happy with the way it looks there. If you actually want to create a HTML file, you should write your data to a HTML file and look at that. (When you don't have the correct settings for cmd.exe, or an incorrect console font, Unicode characters might not show up. That does not mean your output is wrong, it means cmd.exe can't display it correctly.) – Tomalak Sep 06 '20 at 11:41
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/221042/discussion-between-community-ans-and-tomalak). – MeirDayan Sep 06 '20 at 11:49
  • Ok. it is better to test fixing cmd setting. maybe it fix my problem. So, do u have any solutio for fixing cmd? @Tomalak – MeirDayan Sep 06 '20 at 11:51
  • 1
    Again. If you want to write HTML, cmd.exe is not your problem. Write HTML files and look at *them*. – Tomalak Sep 06 '20 at 11:54
  • @Tomalak I don't want to write html. Have you ever worked with robotjs? It simulates clicking and writing like mouse and keyboards. So, the problem is not creating html! problem is: "Why robotjs not support persian?" – MeirDayan Sep 06 '20 at 11:57
  • Robot.js supports Persian. You need to think about what I have told you. – Tomalak Sep 06 '20 at 12:29

0 Answers0