Created
March 9, 2018 13:19
-
-
Save tim6her/a2d1839eec890915c1496abd2a93c961 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
from __future__ import absolute_import, print_function, division | |
from itertools import combinations_with_replacement | |
import latexcodec | |
chars = ((r'\"{o} ', r'{ö} '), | |
(r'{\"o} ', r'{ö} '), | |
(r'\L ', 'Ł'), | |
(r'{\L} ', r'{Ł} '), | |
('u ', 'u ')) | |
def dot_or_F(tex, uni): | |
code = tex.encode('ascii') | |
uni_tex = code.decode('latex') | |
if uni_tex.strip() == uni.strip(): | |
return ('.', uni_tex) | |
return ('F', uni_tex) | |
print('{code}:\t{tex}\t{uni_tex}'.format(tex='tex code'.ljust(19), | |
code=' ', uni_tex='encoded output')) | |
for cc in combinations_with_replacement(chars, 3): | |
ttex, uuni = list(zip(*cc)) | |
tex = ''.join(ttex) | |
uni = ''.join(uuni) | |
code, uni_tex = dot_or_F(tex, uni) | |
print('{code}:\t{tex}\t{uni_tex}'.format(tex=tex.ljust(19), | |
code=code, uni_tex=uni_tex)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment