unit InitConsoleCodepageUTF8;
{$mode objfpc}{$H+}
interface
implementation
uses windows;
const
LF_FACESIZE = 32;
type
CONSOLE_FONT_INFOEX = record
cbSize : ULONG;
nFont : DWORD;
dwFontSizeX : SHORT;
dwFontSizeY : SHORT;
FontFamily : UINT;
FontWeight : UINT;
FaceName : array [0..LF_FACESIZE-1] of WCHAR;
end;
function SetCurrentConsoleFontEx(hConsoleOutput: HANDLE; bMaximumWindow: BOOL; var CONSOLE_FONT_INFOEX): BOOL; stdcall; external 'kernel32.dll' name 'SetCurrentConsoleFontEx';
var
New_CONSOLE_FONT_INFOEX : CONSOLE_FONT_INFOEX;
initialization
SetConsoleOutputCP(CP_UTF8);
SetTextCodepage(Output, CP_UTF8);
FillChar(New_CONSOLE_FONT_INFOEX, SizeOf(CONSOLE_FONT_INFOEX), 0);
New_CONSOLE_FONT_INFOEX.cbSize := SizeOf(CONSOLE_FONT_INFOEX);
New_CONSOLE_FONT_INFOEX.FaceName := 'Lucida Console';
New_CONSOLE_FONT_INFOEX.FontWeight := 400;
SetCurrentConsoleFontEx(StdOutputHandle, False, New_CONSOLE_FONT_INFOEX);
end.