Download Pelles C here: http://www.pellesc.se
OS_DOMAINMEMBER equ 28
ExitProcess PROTO :QWORD
IsOS PROTO :QWORD
printf PROTO :QWORD,:VARARG
.data
m1 db 'The computer is not joined to a domain.',0
m2 db 'The computer is joined to a domain.',0
tbl dq OFFSET m1,OFFSET m2
.data?
rv dq ?
.code
start:
sub rsp,4*8+8
invoke IsOS,OS_DOMAINMEMBER
xor rdx,rdx
test rax,rax
setne dl
mov rv,rdx
shl rdx,3
lea rax,[tbl+rdx]
invoke printf,QWORD PTR [rax]
invoke ExitProcess,rv
END start
BOOL SetConsoleFontToConsolas(void)
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
if (hConsole == INVALID_HANDLE_VALUE) return FALSE;
CONSOLE_FONT_INFOEX cfi;
cfi.cbSize = sizeof(CONSOLE_FONT_INFOEX);
// Get the current font info first to preserve defaults
if (!GetCurrentConsoleFontEx(hConsole, FALSE, &cfi))
{
return FALSE;
}
// Set font properties
cfi.dwFontSize.X = 0; // Width (0 lets Windows calculate based on height)
cfi.dwFontSize.Y = 16; // Height (Font size in points/pixels)
cfi.FontFamily = FF_DONTCARE;
cfi.FontWeight = FW_NORMAL;
// Specify a TrueType font that supports UTF-8 Unicode characters
// Common choices: L"Cascadia Code", L"Consolas", L"Lucida Console"
wcscpy_s(cfi.FaceName, LF_FACESIZE, L"Consolas");
// Apply the new font
return SetCurrentConsoleFontEx(hConsole, FALSE, &cfi);
}QuoteThe functions SetConsoleOutputCP and SetConsoleCP along with the CP_UTF8 code page constant (code page 65001) have been supported since Windows 2000.
However, the minimal OS version depends on what you are trying to achieve:
Basic Function Support (API availability): Windows 2000 or later. Calling SetConsoleOutputCP(65001) is supported on all Windows NT-based OS versions starting from 2000, as well as Windows XP, Vista, 7, 8, and 10.
Functional UTF-8 Console Rendering: Windows 10 Version 1903 (Build 18362) or later.
Why the distinction matters:
While the functions exist on older OS versions, UTF-8 support inside cmd.exe on legacy releases (Windows 7/8/early Win 10) was notoriously buggy:
Legacy Bugs: On older versions like Windows 7, setting the console to code page 65001 frequently broke C runtime output routines (printf), caused character truncation, or crashed batch scripts.
Font Rendering: Legacy consoles couldn't render multi-byte UTF-8 sequences properly unless using specific TrueType fonts.
Full ConPTY Overhaul: Microsoft fully overhauled the Windows Console infrastructure in Windows 10 version 1903 (Build 18362)—the exact same release that introduced manifest-based UTF-8 ACP support—making UTF-8 output reliable and stable in the terminal.
Page created in 0.025 seconds with 11 queries.