MCPcopy Index your code
hub / github.com/RustPython/RustPython / is_code_page_present

Function is_code_page_present

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 4

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

Tested by

no test coverage detected