Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Using Russian letters in the program

31 views
Skip to first unread message

Alex Tuchin

unread,
Apr 7, 2024, 5:17:03 AM4/7/24
to dislin-users
Hi!
When the program:
int main ()
{
  int screen_width, screen_height;
  g.getscr (&screen_width, &screen_height);
  g.swgwin (0, 0, screen_width, screen_height);
  g.chacod("iso5");
  g.winfnt("Consolas");
  g.swgtit ("Изучение Dislin study");
  int id_main = g.wgini ("form");
  int colBorderX = 30;
  int colBorderY = 30;
  int wgX = 150;
  int wgY = 20;
  int id_basbtn  = g.wgbas (id_main, "form");
  g.swgwin (colBorderX, colBorderY, wgX, wgY);
  int id_but  = g.wgpbut (id_basbtn, "Старт");
  g.wgfin ();
  return 0;
}
 is started, Russian letters are displayed in incomprehensible characters. I receive a message in the terminal window:
 <<<< Warning 3: Incorrect level in chacod!   ( 0)
 <<<< Warning 3: Incorrect level in winfnt!   ( 0)
Please tell me how to make Russian letters display correctly.

Helmut Michels

unread,
Apr 10, 2024, 4:26:33 PM4/10/24
to dislin-users
Hi Alex,

the routines chacod and winfnt belong to the plotting section and not to the widget
routines. You have to use swgopt (copt, "coding") for the coding and swgfnt for setting
a Unicode font. For example:

-----
void main()
{ int i, ip, id, n, iray[20];
  char s[81];

  for (i = 0; i < 20; i++)
    iray[i] = 1024 + i;

  n = intutf (iray, 20, s, 80);
  swgopt ("utf8", "coding");
  swgfnt ("Arial Bold", 14);
  swgwth (40);
  ip = wgini ("vert");
  id = wglab (ip, s);
  wgfin ();
}
-----

In the code above I have converted some Unicode numbers to a UTF-8 string
and passed the string to a widget routine. If your editor creates UTF-8
output,  you can use this output directly in the widget routines. ISO5 coding
should work in the same way.

With best regards,

Helmut

Alex Tuchin

unread,
Apr 11, 2024, 7:40:53 AM4/11/24
to dislin-users
Hi, Helmut!

Thank you very much! I changed your code a little and the Russian letters began to display correctly
int main ()
{

  int ip = g.wgini ("hori");
  g.swgopt("russian", "coding");
  g.swgwth (50);
  int id = g.wglab (ip, "Изучение Study Dislin");
  g.wgfin ();
  return 0;
}

With best regards, Alex

среда, 10 апреля 2024 г. в 23:26:33 UTC+3, mic...@dislin-software.de:

Alex Tuchin

unread,
Apr 13, 2024, 11:27:58 AM4/13/24
to dislin-users
I was happy early. I started the program:

int main ()
{

  int ip = g.wgini ("hori");
  g.swgopt("russian", "coding");
  g.swgwth (50);
  int id = g.wglab (ip, "Изучение Study Dislin");
  g.wgfin ();
  return 0;
}

 on another computer (the same Russian Windows 10) again, incomprehensible symbols appeared instead of Russian letters. What could be the matter?

четверг, 11 апреля 2024 г. в 14:40:53 UTC+3, Alex Tuchin:

Alex Tuchin

unread,
Apr 13, 2024, 12:18:02 PM4/13/24
to dislin-users
I found the reason. In Windows, the source code file must be encoded in Windows-1251. Then it works:
swgopt("russian", "coding");
If the Windows source code file is UTF-8, only English letters are output correctly, Russian letters are output incorrectly.
Do I understand correctly that in Windows, if the file is UTF-8, then all string need to be translated to Windows-1251? Does Dislin have such a function or do I need to use C++ functions?

суббота, 13 апреля 2024 г. в 18:27:58 UTC+3, Alex Tuchin:
Reply all
Reply to author
Forward
0 new messages