Author Topic: C-files & DOS Cyrillic encoding  (Read 9986 times)

SuperSailorMoon

  • Guest
C-files & DOS Cyrillic encoding
« on: January 01, 2008, 03:17:34 pm »
Can I customise Code::Blocks somehow to source text saving (for example, .c file) in format OEM 866 (DOS Cyrillic)? Otherwise non-Latin characters are displayed incorrectly in console applications.


OEM 866 is absent in Default encoding when opening files: list. Perhaps, is it possible to add this encoding somehow?

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: C-files & DOS Cyrillic encoding
« Reply #1 on: January 01, 2008, 04:20:45 pm »
If C::B can display it properly, it indicates that the file is saved properly. But while compiling, the compiler is getting confused.

Try adding -finput-charset=CP1251 command to compiler options. :)
Be a part of the solution, not a part of the problem.

SuperSailorMoon

  • Guest
Re: C-files & DOS Cyrillic encoding
« Reply #2 on: January 01, 2008, 11:33:36 pm »
The file, used in the picture above, is saved in Windows 1251 format. If it is saved as OEM 866, the text in editor window is displayed incorrectly, however the compiled program displays this text correctly.



How to make WYSIWYG?

SuperSailorMoon

  • Guest
Re: C-files & DOS Cyrillic encoding
« Reply #3 on: January 02, 2008, 04:25:21 pm »
I have solved this problem!
1. It is necessary to change default font for console applications. That is, to change standard dot font to vector font, such as Consolas or Lucida Console. Take advantage of this .reg file:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Console]
"ScreenColors"=dword:0000000f
"FontSize"=dword:00100000
"FontFamily"=dword:00000036
"FontWeight"=dword:000002bc
"FaceName"="Consolas"


for Consolas, or this:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Console]
"FontSize"=dword:000e0000
"FontWeight"=dword:00000190
"FaceName"="Lucida Console"
"FontFamily"=dword:00000036
"ScreenColors"=dword:0000000f


for Lucida Console.

2. It is necessary to add following lines in a program code:
#include <Windows.h>
and
SetConsoleOutputCP (1251);

« Last Edit: January 02, 2008, 04:31:44 pm by SuperSailorMoon »

Offline ivucica

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: C-files & DOS Cyrillic encoding
« Reply #4 on: January 02, 2008, 05:11:43 pm »
I have solved this problem!
<snip>
Seems more like an ugly hack than a problem solution to me. An end user will not be willing to do the registry hack that you're doing, and it's probably much easier to add a new CP to C::B's editor than to convince users to replace their default font. (We may like it, but the end users won't. And they'll like automatization even less.)

Regarding GNU/Linux machines, I don't know about their Cyrillic configuration (I didn't even fix it up for my Croatian == Central European glyphs), but it doesn't sound to me like most people will adapt their OS installation to suit their programs. If the distributions use CP 866, then coding for  such distros is a bit harder with C::B.

Ok, I'll stfu. :)

SuperSailorMoon

  • Guest
Re: C-files & DOS Cyrillic encoding
« Reply #5 on: January 02, 2008, 06:19:51 pm »
I wish Code::Blocks editor supported OEM 866 codepage... But it is absent, unfortunately.

Offline Albenejean

  • Multiple posting newcomer
  • *
  • Posts: 65
Re: C-files & DOS Cyrillic encoding
« Reply #6 on: January 02, 2008, 06:36:41 pm »
Well, I don't know if this is related to CB. I thinks it's due to windows or to C++.

I can play whith CB all the time, the only way I know to display french caracters in a console is to use
Code
setlocale(LC_CTYPE,"french");

SuperSailorMoon

  • Guest
Re: C-files & DOS Cyrillic encoding
« Reply #7 on: January 02, 2008, 07:11:54 pm »
Well, I don't know if this is related to CB. I thinks it's due to windows or to C++.

I can play whith CB all the time, the only way I know to display french caracters in a console is to use
Code
setlocale(LC_CTYPE,"french");

Many thanks, Albenejean! This way has helped:

setlocale(LC_ALL,".ACP");