2022-05-19 10:37:06 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
import char_encodings
|
|
|
|
|
2022-12-30 16:39:20 +00:00
|
|
|
if len(sys.argv) == 2:
|
|
|
|
decoded = sys.argv[1]
|
|
|
|
else:
|
|
|
|
decoded = input()
|
2022-05-19 10:37:06 +00:00
|
|
|
|
|
|
|
singlebyte = {}
|
|
|
|
multibyte = {}
|
|
|
|
|
|
|
|
for encoding in char_encodings.encodings:
|
|
|
|
try:
|
|
|
|
encoded = decoded.encode(encoding)
|
|
|
|
except UnicodeEncodeError:
|
|
|
|
continue
|
|
|
|
|
|
|
|
if len(encoded) == len(decoded):
|
|
|
|
if encoded not in singlebyte: singlebyte[encoded] = []
|
|
|
|
singlebyte[encoded].append(encoding)
|
|
|
|
else:
|
|
|
|
if encoded not in multibyte: multibyte[encoded] = []
|
|
|
|
multibyte[encoded].append(encoding)
|
|
|
|
|
|
|
|
for encoded, encodings in singlebyte.items():
|
|
|
|
print(f'{",".join(encodings)}: {encoded.hex()}')
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
for encoded, encodings in multibyte.items():
|
|
|
|
print(f'{",".join(encodings)}: {encoded.hex()}')
|