invoke GetUName() from getuname.dll using ctypes in python

Here’s a way to lookup a Unicode character’s full name, using Windows built-in getuname.dll, which is the core component of CharMap.exe.

>>> import ctypes, ctypes.wintypes
>>> dwCodePoint = ctypes.wintypes.DWORD( ord('&') )
>>> lpBuffer = ctypes.create_unicode_buffer(255)
>>> ctypes.windll.getuname.GetUName(dwCodePoint , ctypes.byref(lpBuffer))
2 #length of returned lpBuffer
>>> print lpBuffer.value
与号 #Localized name of the Unicode character '&'

The GetUName() function is an undocumented Win32 API, learned from 1, 2, 3

Comments