def is_encodable(encoding, text): try: text.encode(encoding, 'strict') except UnicodeEncodeError: return False else: return True CODE_PAGES = ( 'cp874', 'cp932', 'cp936', 'cp949', 'cp950', 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', 'cp1256', 'cp1257', 'cp1258', ) def check(text): match = [encoding for encoding in CODE_PAGES if is_encodable(encoding, text)] if match: print("%r is encodable to %s" % (text, ', '.join(match))) else: print("%r is not encodable to any code page" % (text,)) check(unichr(0x301)) check(unichr(0x363)) check(unichr(0x2661)) check(unichr(0x5171)) check(u"\u2661\u5171") check(u"\u0301\u0363\u2661\u5171")