You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
696 B
32 lines
696 B
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()}')
|
|
|