This application demonstrates mixing of text written in many European alphabets both in graphic and console window. Sample text is written in UTF-8 encoding here in this source file, no codepage switching is necessarry.
Sample text is displayed in a message box first using its default font.
Then is the same text displayed in console window which launched the application.
Raster console font used as default in older Windows versions does not support glyphs
for non-Latin characters, the text will be displayed correctly only if the user
selects TrueType font in Properties/Font context menu of console window.
In Windows Vista and newer version can the current console font be selected
by the program automatically.
In MS-Windows XP and older the function SetCurrentConsoleFontEx is not available inkernel32.dll. Import of nonexisting function would make Windows to refuse launch of our application, that is why it tries to import the function indirectly, with LoadLibrary and GetProcAddress.
cpmix64.exe
EUROASM AutoSegment=Yes, Unicode=Yes, CodePage=UTF-8, \ CPU=X64, AMD=Yes, SIMD=SSE cpmix64 PROGRAM Format=PE, Width=64, Model=Flat, Subsystem=CON, \ ListLiterals=Yes,ListMap=Yes, ListGlobals=Yes, \ IconFile=, Entry=Start: INCLUDE wins.htm, winscon.htm, winabi.htm ;; Following source Sample text is written in codepage UTF-8 ;; and stored in [.data] segment in UTF-16 (WIDE) encoding. Sample D "Sample text of mixed alphabets:",13,10 D "Éireannach (Eireannach in western European alphabet)",13,10 D "Čapek (Capek in central European alphabet)",13,10 D "Ørsted (Oersted in Nordic alphabet)",13,10 D "Aukštaičių (Aukstaciu in Baltic alphabet)",13,10 D "Ὅμηρος (Homer in Greek alphabet)",13,10 D "Yumuşak ğ (Yumushak g in Turkish alphabet)",13,10 D "Maðkur (Mathkur in Icelandic alphabet)",13,10 D "דגבא (ABGD in Hebrew alphabet)",13,10 D "Достоевский (Dostoevsky in Cyrillic alphabet)",13,10 D " ",13,10 D "If the text is not displayed correctly in console window,",13,10 D "you may need to select TrueType font (Consolas or Lucida Console)",13,10 D "in Properties of the console and run the program again.",0 ;; Declare requested console font. ConsoleFontInfoEx DS CONSOLE_FONT_INFOEX, .cbSize=SIZE#CONSOLE_FONT_INFOEX, \ .FaceName="Lucida Console" Start: NOP ; Machine instruction tells €ASM to switch to [.text] (AutoSegment=Yes). ; Display Sample using graphic message box. WinABI MessageBox, 0,Sample,="%^PROGRAM",0, Lib=user32.dll ; Try to change default console raster font to TrueType. WinABI GetModuleHandle, ="kernel32" WinABI GetProcAddress,RAX,=B"SetCurrentConsoleFontEx" TEST RAX JZ .Skip: ; When WinAPI SetCurrentConsoleFontEx is not available (NT,2K,XP). MOV RSI,RAX ; ESI is now entry point of function SetCurrentConsoleFontEx. WinABI GetStdHandle,STD_OUTPUT_HANDLE ; Get handle of default console. WinABI RSI,RAX,1,ConsoleFontInfoEx ; Select TT font for the current console window. .Skip: ; If console font could not be changed programatically, all we can do is ask the user. ; Display Sample using console output. StdOutput Sample, Console=Yes TerminateProgram ENDPROGRAM cpmix64