MCPcopy Index your code
hub / github.com/python/cpython / is_code_page_present

Function is_code_page_present

Lib/test/test_codecs.py:40–58  ·  view source on GitHub ↗
(cp)

Source from the content-addressed store, hash-verified

38
39# On small versions of Windows like Windows IoT or Windows Nano Server not all codepages are present
40def is_code_page_present(cp):
41 from ctypes import POINTER, WINFUNCTYPE, WinDLL, Structure
42 from ctypes.wintypes import BOOL, BYTE, WCHAR, UINT, DWORD
43
44 MAX_LEADBYTES = 12 # 5 ranges, 2 bytes ea., 0 term.
45 MAX_DEFAULTCHAR = 2 # single or double byte
46 MAX_PATH = 260
47 class CPINFOEXW(Structure):
48 _fields_ = [("MaxCharSize", UINT),
49 ("DefaultChar", BYTE*MAX_DEFAULTCHAR),
50 ("LeadByte", BYTE*MAX_LEADBYTES),
51 ("UnicodeDefaultChar", WCHAR),
52 ("CodePage", UINT),
53 ("CodePageName", WCHAR*MAX_PATH)]
54
55 prototype = WINFUNCTYPE(BOOL, UINT, DWORD, POINTER(CPINFOEXW))
56 GetCPInfoEx = prototype(("GetCPInfoExW", WinDLL("kernel32")))
57 info = CPINFOEXW()
58 return GetCPInfoEx(cp, 0, info)
59
60class Queue(object):
61 """

Callers 1

Calls 4

WINFUNCTYPEFunction · 0.90
POINTERFunction · 0.90
WinDLLClass · 0.90
CPINFOEXWClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…