When Using Cmd Terminal Python Can't Display Hebrew
Solution 1:
This will affect the Command (CMD) console.
Open regedit.exe and navigate to this location:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
Occasionally you will see two values named
0
and00
. Add a third String Value and name it:000
(Zero three times).In this new
000
String Value, enterCourier New
(case sensitive) in the Value Data field.Now open Powershell (this work for CMD as well) and go to
properties
: Left click on top left Powershell icon and selectproperties
.Go to
Font
tab and select theCourier New
font:
Now you should see Hebrew when you switch to Hebrew writing (backwards view). This enables you to send output Hebrew writing from a script for instance.
Solution 2:
I have a solution. Change console font in Windows There is a code there to change the font. I found out it also works for fonts that are usually not supported by CMD.
according to the answer:
import ctypes
LF_FACESIZE = 32
STD_OUTPUT_HANDLE = -11classCOORD(ctypes.Structure):
_fields_ = [("X", ctypes.c_short), ("Y", ctypes.c_short)]
classCONSOLE_FONT_INFOEX(ctypes.Structure):
_fields_ = [("cbSize", ctypes.c_ulong),
("nFont", ctypes.c_ulong),
("dwFontSize", COORD),
("FontFamily", ctypes.c_uint),
("FontWeight", ctypes.c_uint),
("FaceName", ctypes.c_wchar * LF_FACESIZE)]
font = CONSOLE_FONT_INFOEX()
font.cbSize = ctypes.sizeof(CONSOLE_FONT_INFOEX)
font.nFont = 12
font.dwFontSize.X = 11
font.dwFontSize.Y = 18
font.FontFamily = 54
font.FontWeight = 400
font.FaceName = "Lucida Console"
handle = ctypes.windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
ctypes.windll.kernel32.SetCurrentConsoleFontEx(
handle, ctypes.c_long(False), ctypes.pointer(font))```
Post a Comment for "When Using Cmd Terminal Python Can't Display Hebrew"