Delphi – Unicode Console Application in Delphi 2009

consoledelphidelphi-2009unicode

How can I create unicode console application with Delphi 2009?

If I do like this:

{$APPTYPE CONSOLE}
uses
  SysUtils;
begin
  writeln('öüğşç سيمانتت');
end.

I get the following:

ougsc ???????

Best Answer

I'm not sure that is what you're after, but you can create Unicode console applications in all 32-bit Delphi versions by using the Windows API functions. I just tried with Delphi 4:

program test;

{$APPTYPE CONSOLE}

uses
  Windows;

var
  s: WideString;
  i: integer;
  Written: Cardinal;
begin
  SetLength(s, 80);
  for i := 1 to 80 do
    s[i] := WideChar(48 + i);
  WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), PWideChar(s), 80, Written,
    nil);
end.

I don't have Delphi 2009 to try how entering Unicode strings in the editor works...