| Index | Manual | Download | Source | Macros | Embedded word Case ins.
Sitemap | Links | Forum | Tests | Projects

# cpmix32.htm

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 message box, 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 the current console font can be selected by the program automatically.

> In MS Windows XP and older the function SetCurrentConsoleFontEx is not available in kernel32.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.

Format
  PE 32-bit FLAT CON
Platform
  MS Windows. It works in 32-bit and 64-bit Windows.
Build
  `euroasm cpmix32.htm`
Run
  `cpmix32.exe`

            EUROASM AutoSegment=Yes, Unicode=Yes, CodePage=UTF-8
    cpmix32 PROGRAM Format=PE, Width=32, Model=Flat, Subsystem=CON, \
                    ListLiterals=Yes, ListMap=Yes, ListGlobals=Yes, \
                    IconFile=, Entry=Start:
            INCLUDE wins.htm, winscon.htm, winapi.htm
            ;; Following source Sample text is written in the 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ų (Aukshtaiciu in Baltic alphabet)",13,10
     D "Ὅμηρος (Homer in Greek alphabet)",13,10
     D "Yumuşak ğ (Yumushak g in Turkish aplhabet)",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
       ;; Statically declare requested console font in [.data] segment.
    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.
       WinAPI MessageBox, 0,Sample,="%^PROGRAM",0, Lib=user32.dll
       ; Try to change default console raster font to TrueType.
       WinAPI GetModuleHandle, ="kernel32"
       WinAPI GetProcAddress,EAX,=B"SetCurrentConsoleFontEx"
       TEST EAX
       JZ .Skip:                             ; Skip when WinAPI SetCurrentConsoleFontEx is not available (NT,2K,XP).
       MOV ESI,EAX                           ; ESI is now the entry point of the function SetCurrentConsoleFontEx.
       WinAPI GetStdHandle,STD_OUTPUT_HANDLE ; Get handle of default console.
       WinAPI ESI,EAX,1,ConsoleFontInfoEx    ; Select TT font for the current console window.
    .Skip: ; Display Sample using console output ; If console font could not be changed programatically, all we can do is ask the user.
       StdOutput Sample, Console=Yes
       TerminateProgram
      ENDPROGRAM cpmix32

▲Back to the top▲