diff options
author | makefu <github@syntax-fehler.de> | 2011-09-23 12:01:21 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2011-09-23 12:01:21 +0200 |
commit | cc74c033c19db59069f9bb5e12670e9916eadcf9 (patch) | |
tree | 7b1433706808f61655094c0bc82d87d6584ee047 /crypto/bin/ukrepl | |
parent | 7d3d099f8de3891e897112906d47cd8428d27122 (diff) |
ukrepl: add punctuation mode
Diffstat (limited to 'crypto/bin/ukrepl')
-rwxr-xr-x | crypto/bin/ukrepl | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/crypto/bin/ukrepl b/crypto/bin/ukrepl index 867f1858..f40e93ea 100755 --- a/crypto/bin/ukrepl +++ b/crypto/bin/ukrepl @@ -1,11 +1,11 @@ #!/usr/bin/python # -*- coding: utf-8 -*- import sys + wont_change = { ' ' : ' ' , '\n' : '\n' } -fixed_active = False -def fixed_width_replace(char): +def fixed_width_replace(char): #f if char in wont_change: return unicode(char) else: try: @@ -14,7 +14,6 @@ def fixed_width_replace(char): except: return char -cyr_active = False cyrillic_dict = { 'A' : u'А', 'a' : 'а','Ä' : u'Ӓ', 'ä' : u'ӓ', 'B' : u'В', @@ -32,9 +31,42 @@ cyrillic_dict = { 'T' : u'г' } -def cyrillic_replace(char): +def cyrillic_replace(char): #c return cyrillic_dict.get(char,unicode(char)) +historic_latin_dict = { + 'B' : u'Ɓ', + 'b' : u'ƅ', + 'u' : u'ư', + 'U' : u'Ư', + '' : 'Ǟ', + #'5' : 'ƽ', + 'o' : 'ơ', + 'O' : 'Ơ', + '5' : 'Ƽ' + } +def historic_latin(char): #H + return historic_latin_dict.get(char,unicode(char)) +punctuation_dict = { + '!' : u'ǃ', + '\'': u'’', + '\"': u'ˮ', + '(' : u'⟨', + ')' : u'⟩', + ':' : u'ː', + #'-' : u'‒', + #'-' : u'—', + #'-' : u'―', + #'-' : u'‐', + #'-' : u'⁃', + '-' : u'–', + '_' : u'−', + '~' : u'⁓', + #'~' : u'∼', + #'~' : u'〜', + } +def punctuation(char): #p + return punctuation_dict.get(char,unicode(char)) def helpme(): print "usage %s [modes]" % sys.argv[0] print "modes:" @@ -57,6 +89,10 @@ for line in sys.stdin: char = cyrillic_replace(char) elif mode is 'f': char = fixed_width_replace(char) + elif mode is 'H': + char = historic_latin(char) + elif mode is 'p': + char = punctuation(char) else: print "unknown mode %c" % mode helpme() |