[fpc-devel] About bug 4928

Maxim Ganetsky ganmax at narod.ru
Thu Mar 30 02:14:47 CEST 2006


Hello.

There is another bug (bug 4928) about charsets and Crt was added to
bugtracker recently:

"Simply include "uses crt;" and your write() output is garbled.
I use Russian language, win32, codepage 1251. Some symbols are
substituted by question marks, some --- by other symbols.
CRT docs don't mention it openly, some other unfixed bugs don't seem to
state this exact problem."

I can add that in this case these problems can be solved by adding to
the program

  SetConsoleCP(1251);
  SetConsoleOutputCP(1251);

from Windows unit.

Example that will work correctly:

uses Windows, crt;
begin
  SetConsoleCP(1251);
  SetConsoleOutputCP(1251);
  ClrScr;
  writeln('Hello World!');
  writeln('Привет, мир!'); //String in Russian, doesn't work correctly
without above trick even in Russian Windows
  readkey;
end.

It would be good to add a trick like this to win32 crt (i.e. set Windows
default charset for console) as it would ease porting of old TP programs
to FPC.

-- 
Best regards,
 Maxim Ganetsky                  mailto:ganmax at narod.ru



More information about the fpc-devel mailing list