It is currently Fri Feb 21, 2020 12:53 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: PureBasic console characters
PostPosted: Wed Mar 04, 2015 9:34 pm 
Offline
Enthusiast
Enthusiast

Joined: Sun Feb 22, 2015 2:33 am
Posts: 139
The character set displayed in a PureBasic Console window are different than displayed in a Debug Window.

Does anyone know what character set is used for Console Window output?
Is it the classic OEM code page 437?

And, importantly, can the character set, or code page, used by PureBasic's console window be changed?

_________________
Think Unicode!


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic console characters
PostPosted: Wed Mar 04, 2015 10:07 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4518
Location: Germany
Hi,

I think PB has no 'console window' it opens a windows console.
You also can run the exe in a cmd window, which is also a 'console window'.

I think it's only possible if you change the windows default console font.

Bernd


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic console characters
PostPosted: Wed Mar 04, 2015 10:40 pm 
Offline
Enthusiast
Enthusiast

Joined: Sun Feb 22, 2015 2:33 am
Posts: 139
Hi infratec,

I have read that the windows console window displays the OEM code page, which is usually 437, at least in North America.

That means only single byte characters would be displayed with codes from 0 to 255.

But, in Unicode mode when using the PB Print or PrintN commands to write to the console, a UCS-2 sting of two byte characters is sent to the console, and the characters are displayed properly.

So there are two possibilities, (1) the Windows cmd console can handle UCS-2 two byte characters and display them properly, or (2) the PB compiler will convert the two byte UCS-2 characters to one byte OEM characters which will then be sent to the windows console.

I think a test program will have to be created to help answer this question.

And I haven't figured out how the windows code page 1252 set of characters comes into play with PureBasic!

_________________
Think Unicode!


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic console characters
PostPosted: Wed Mar 04, 2015 11:09 pm 
Offline
Addict
Addict

Joined: Sun Sep 07, 2008 12:45 pm
Posts: 4518
Location: Germany
Hi,

found something:
http://www.codeproject.com/Articles/340 ... ws-Console

More interesting: (look at Windows NT)
https://en.wikipedia.org/wiki/Win32_console


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic console characters
PostPosted: Wed Mar 04, 2015 11:31 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 8024
Location: Fort Nelson, BC, Canada
Some fooling around (win8.1):
Code:
; HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
;   NT\CurrentVersion\
;   Console\RasterFonts
;    -and- \TrueTypeFont
;         
Structure CONSOLE_FONT_INFOEX
  cbSize.l
  nFont.l
  dwFontSize.COORD
  FontFamily.l
  FontWeight.l
  FaceName.u[#LF_FACESIZE]
EndStructure

Prototype SetConsoleFont(handle, index)
Prototype GetNumberOfConsoleFonts()
Prototype SetCurrentConsoleFontEx(handle, bool, *cfi.CONSOLE_FONT_INFOEX)

OpenLibrary(0, "kernel32.dll")
Global SetConsoleFont_.SetConsoleFont                   = GetFunction(0, "SetConsoleFont")
Global GetNumberOfConsoleFonts_.GetNumberOfConsoleFonts = GetFunction(0, "GetNumberOfConsoleFonts")
Global SetCurrentConsoleFontEx_.SetCurrentConsoleFontEx = GetFunction(0, "SetCurrentConsoleFontEx")

OpenConsole()
n = GetNumberOfConsoleFonts_()
hnd = GetStdHandle_(#STD_OUTPUT_HANDLE)

For i = 0 To n-1
  SetConsoleFont_(hnd, i)
  PrintN("Font "+Str(i)+": The quick brown fox jumped over the lazy dog.")
  Delay(1000)
  CloseConsole()
  OpenConsole()
  hnd = GetStdHandle_(#STD_OUTPUT_HANDLE)
Next

; Set font size and weight
With cfi.CONSOLE_FONT_INFOEX
  \cbSize = SizeOf(CONSOLE_FONT_INFOEX)
  \dwFontSize\X = 0
  \dwFontSize\Y = 48
  \FontWeight = #FW_BOLD
EndWith
PokeS(@cfi\FaceName, "Lucida Console", -1, #PB_Unicode)

SetCurrentConsoleFontEx_(GetStdHandle_(#STD_OUTPUT_HANDLE), 1, @cfi)
PrintN("The quick brown fox jumped over the lazy dog.")
PrintN("The quick brown fox jumped over the lazy dog.")
PrintN("The quick brown fox jumped over the lazy dog.")
PrintN("The quick brown fox jumped over the lazy dog.")
PrintN("The quick brown fox jumped over the lazy dog.")
Input()

CloseLibrary(0)
End

Some of the console fonts on my machine (there are 10, 5 raster and 5 truetype) are unicode fonts, which the OS will automatically switch to if it can't find a character in the current font.

_________________
Veni, vidi, vici.


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic console characters
PostPosted: Thu Mar 05, 2015 1:50 am 
Offline
Enthusiast
Enthusiast

Joined: Sun Feb 22, 2015 2:33 am
Posts: 139
This might prove very useful in experimenting with changing fonts in a console.

Console
http://sourceforge.net/projects/console/

Description

Console is a Windows console window enhancement. Console features include: multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable font, different window styles

The idea is to configure a font, run Console, then run a PureBasic console exe from withing the window and see what happens when the font is changed.

_________________
Think Unicode!


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic console characters
PostPosted: Thu Mar 05, 2015 9:21 am 
Offline
Enthusiast
Enthusiast

Joined: Sun Feb 22, 2015 2:33 am
Posts: 139
Here is some info about the Lucida Console font.
From this we can see why only a limited number of Unicode characters can be displayed in Console Window

From:
http://www.microsoft.com/typography/fon ... ?fmid=1262

Font Name: Lucida Console
Version: 5.00

Unicode Ranges:
Basic Latin
Latin-1 Supplement
Latin Extended-A
Latin Extended-B
Greek and Coptic
Cyrillic,
Cyrillic Supplementary
General Punctuation
Box Drawing
Block Elements

Code Pages:
1252 Latin 1
1250 Latin 2: Eastern Europe
1251 Cyrillic
1253 Greek
1254 Turkish
869 IBM Greek
866 MS-DOS Russian
865 MS-DOS Nordic
863 MS-DOS Canadian French
861 MS-DOS Icelandic
860 MS-DOS Portuguese
857 IBM Turkish
855 IBM Cyrillic; primarily Russian
852 Latin 2
737 Greek; former 437 G
850 WE/Latin 1
437 US

_________________
Think Unicode!


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic console characters
PostPosted: Thu Mar 05, 2015 9:26 am 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 8024
Location: Fort Nelson, BC, Canada
http://en.wikipedia.org/wiki/Fallback_font

Ten console fonts on my computer, several are unicode. All are fallbacks.

_________________
Veni, vidi, vici.


Last edited by netmaestro on Thu Mar 05, 2015 10:00 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic console characters
PostPosted: Thu Mar 05, 2015 9:55 am 
Offline
Enthusiast
Enthusiast

Joined: Sun Feb 22, 2015 2:33 am
Posts: 139
Thank you netmaestro for mentioning Fallback fonts. I had never heard of them before.

When I look at Fonts in the properties of a cmd window, I only see Lucida Console and Raster Fonts listed.

_________________
Think Unicode!


Top
 Profile  
Reply with quote  
 Post subject: Re: PureBasic console characters
PostPosted: Fri Mar 06, 2015 9:29 pm 
Offline
Enthusiast
Enthusiast

Joined: Sun Feb 22, 2015 2:33 am
Posts: 139
This might be useful for reference.

Code Page Identifiers
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

Usually the console is set to cp437 (OEM).

Code page 65001 will allow the console to display UTF-8 encoded text.

Another useful page is:

https://msdn.microsoft.com/en-us/goglobal/ff678782.aspx

that gives the default code pages for older versions of Windows and MS-DOS.

_________________
Think Unicode!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye