33 lines
696 B
Python
33 lines
696 B
Python
import sys
|
|
|
|
import char_encodings
|
|
|
|
if len(sys.argv) == 2:
|
|
decoded = sys.argv[1]
|
|
else:
|
|
decoded = input()
|
|
|
|
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()}')
|