Created
March 30, 2013 16:20
-
-
Save Sanqui/5277308 to your computer and use it in GitHub Desktop.
Converts file from Kamenický encoding/KEYBCS2/CP895, a legacy Czechoslovak encoding, to system Unicode. Not even iconv supports this!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
from sys import argv | |
highchars = 'üéďäĎŤčěĚĹÍľĺÄÁÉžŽôöÓůÚýÖÜŠĽÝŘťáíóúňŇŮÔšřŕŔ¼§«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■' | |
out = "" | |
with open(argv[1], 'rb') as f: | |
for byte in f.read(): | |
if byte < 128: | |
out += chr(byte) | |
else: | |
out += highchars[byte-129] | |
print(out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, but I think that you're missing character 'Č' at position 128, that will therefore be translated to highchars[-1]