How do I write Unicode characters in a console window? I've Googled and the most common answer is either use UTF8String
or set the Codepage using SetConsoleOutputCP
but I can't get it to work! The Danish letter ø isn't displaying correctly.
I DID read this question: Is Writeln capable of supporting Unicode? and I DID try out the code before posting my own question.
A little test program:
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils, Winapi.Windows;
var
HolidayName: String;
begin
HolidayName := 'Palmesøndag'; // Palm Sunday in Danish
Writeln(HolidayName);
Writeln(UTF8String(HolidayName));
SetConsoleOutputCP(TEncoding.UTF8.CodePage);
Writeln(HolidayName);
Readln;
end.
And the result is:
So in short what am I doing wrong?