Skip to main content
Dmitriy K.
Known Participant
July 25, 2020
Answered

How to use Cyrillic in your code

  • July 25, 2020
  • 1 reply
  • 1643 views

Is it possible to use Cyrillic characters in the Javascript code, for example:

app.addMenuItem({ cName: "test", cUser: "test", cParent: "Help", nPos: -1, 
		cExec: "test()", cEnable: "event.rc = (event.target != null);"}); 
function test() {
app.alert("Привет!", 3);
}

Instead of Cyrillic characters, the function "app.alert" displays a set of characters corresponding to the CP1361 encoding (according to the online encoder).
Does anyone have any experience with this issue?

This topic has been closed for replies.
Correct answer try67

It works when you run it from the console, but it doesn't work when you place the code in a text file, no matter the encoding (as far as I could see, at least). The way around it is to use the Unicode escape codes. For example, the first letter ("П") in your text can be displayed like this:

app.alert("\u041f", 3);

So you just need to convert your string to Unicode characters and then you'll be able to display it. Not ideal, but it works...

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 26, 2020

It works when you run it from the console, but it doesn't work when you place the code in a text file, no matter the encoding (as far as I could see, at least). The way around it is to use the Unicode escape codes. For example, the first letter ("П") in your text can be displayed like this:

app.alert("\u041f", 3);

So you just need to convert your string to Unicode characters and then you'll be able to display it. Not ideal, but it works...

Dmitriy K.
Known Participant
July 26, 2020

Works! Again, thank you. Incredibly, I would never have thought of this decision!