Last active
December 7, 2015 01:48
-
-
Save miettal/38bd9f07baa80a0e18a2 to your computer and use it in GitHub Desktop.
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
text = open('./no-network.txt').read().replace('\n', '') | |
utf9_array = [] | |
i = 0 | |
print len(text) | |
while i < len(text) : | |
utf9 = (int(text[i])<<6) + (int(text[i+1])<<3) + int(text[i+2]) | |
utf9_array.append(utf9) | |
i += 3 | |
i = 0 | |
print len(utf9_array) | |
ucs4_array = [] | |
while i < len(utf9_array) : | |
nonet = utf9_array[i]; i+=1 | |
ucs4 = nonet & 0xff | |
while nonet & 0x100 : | |
ucs4 <<= 8; | |
nonet = utf9_array[i]; i+=1 | |
ucs4 |= nonet & 0xff | |
ucs4_array.append(ucs4) | |
i = 0 | |
byte_array = '' | |
print len(ucs4_array) | |
while i < len(ucs4_array) : | |
byte_array += unichr(ucs4_array[i]).encode('utf-8') | |
i += 1 | |
print len(byte_array) | |
print byte_array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment