[wingide-users] Display Unicode strings in console?
initcontact at grahamwideman.com
Wed Mar 19 19:21:39 EDT 2014
Thanks John for that crucial info.
On further reading (and for the benefit of other list members), here's what I think is the mechanism that allows the WingIDE Debug I/O window to display characters that don't have glyphs in the selected font:
Per John's info, python print() --> Wing Debug I/O window --> scintilla --> QT
Then presumably, QT --> Windows API.
It turns out that Windows API functions can detect characters that lack a glyph and substitute a different font. Apparently this capability is not invoked universally -- perhaps some APIs don't do this, or there are some constraints on when it occurs.
It looks to me like my example print() of character \u265E, with Consolas selected, results in display of the glyph from Lucida Sans Unicode.
That is very satisfactory :-).
I did not get font substitution behavior on windows console (cmd.exe) or PowerShell, but did not explore this vigorously.
Also, a small disambiguation: Stephan wrote:
> In Wing you need to set the Debugger > I/O > Debug I/O
> Encoding preference to match the encoding of the text
> you are printing from your Python code.
My understanding is that in python 3.x, (a) "the text", assuming it's a str, doesn't have a particular encoding (ie: particular byte representation). (b) when output via print(), Python queries the destination for the encoding that the destination wants, and encodes the string to that form. Hence different results when changing cmd.exe's code page using the chcp command. (Or changing WingIDE's Debug I/O encoding preference setting.)
At 3/19/2014 02:35 PM, Wing IDE Support wrote:
>On 3/19/14, 5:18 PM, Graham Wideman wrote:
>>I assume it's the "Editor Font" in the Debug I/O window: Consolas.
>>Looking at Consolas in Windows Character Map (or using a font editor), code point \u265E doesn't seem to have a glyph.
>>In agreement with that finding, the same code in cmd.exe (with font set to Consolas, and after chcp 65001), the string will print, but the Knight character appears as a generic [?] box.
>>So -- how does WingIDE manage to show the correct glyph?
>I think the editor component that Wing uses (scintilla) or the qt layer beneath it is using a font with the glyph for those code points. Wing does not ship with any private fonts.
More information about the wingide-users