-
Notifications
You must be signed in to change notification settings - Fork 0
/
charset_test.py
executable file
·53 lines (49 loc) · 2.6 KB
/
charset_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
import string, sys, os, codecs, re, subprocess
class Charsets:
Symbol = [
['A','Α'], ['B','Β'], ['G','Γ'], ['D','Δ'], ['E','Ε'], ['Z','Ζ'], ['H','Η'],
['Q','Θ'], ['I','Ι'], ['K','Κ'], ['L','Λ'], ['M','Μ'], ['N','Ν'], ['X','Ξ'],
['O','Ο'], ['P','Π'], ['R','Ρ'], ['S','Σ'], ['T','Τ'], ['U','Υ'], ['F','Φ'],
['C','Χ'], ['Y','Ψ'], ['W','Ω'], ['a','α'], ['b','β'], ['g','γ'], ['d','δ'],
['e','ε'], ['z','ζ'], ['h','η'], ['q','θ'], ['i','ι'], ['k','κ'], ['l','λ'],
['m','μ'], ['n','ν'], ['x','ξ'], ['o','ο'], ['p','π'], ['r','ρ'], ['V','ς'],
['s','σ'], ['t','τ'], ['u','υ'], ['f','φ'], ['c','χ'], ['y','ψ'], ['w','ω'],
['J','ϑ'], ['j','ϕ'], ['v','ϖ'], ['"','᾽'], ['#','῎'], ['$','῎'], ['%','῞'],
["'",'᾽'], ['+','΅'], ['/','΄'], [':','῾'], [';','῾'], ['\\','`'],['^','῞'],
['`','ͺ']
]
BQTGrk = Symbol
BQTHeb = [
['"','ַ'], ['#','ֲ'], ['$','ֳ'], ['%','ֱ'], ["'",'ַ'], ['+','ּ'], ['/','ָ'],
[';','ְ'], ['=','ּ'], ['C','ֻ'], ['F',' ׂ'], ['I','ִ'], ['K','ך'], ['M','ם'],
['N','ן'], ['P','ף'], ['S',' ׂ'], ['U','ץ'], ['V',' ׁ'], ['[','ֵ'], ['\\',' ׇ'],
[']','ֶ'], ['_','ְ'], ['a','א'], ['b','ב'], ['c','ֻ'], ['d','ד'], ['e','ע'],
['f',' ֹ'], ['g','נ'], ['h','ה'], ['i',' ׅ'], ['j','ט'], ['k','כ'], ['l','ל'],
['m','מ'], ['n','נ'], ['o','ס'], ['p','פ'], ['q','ק'], ['r','ר'], ['s','ש'],
['t','ת'], ['u','צ'], ['v','ש'], ['w','ו'], ['x','ח'], ['y','י'], ['z','ז'],
['{','ֵ'], ['}','ֶ']
]
HebrewFonts = [Charsets.BQTHeb]
#перевод текста к правильному набору символов. Нужно поскольку некоторые
#модули используют для отображения некоторых языков (греческого, например)
#шрифты с расположением символов, не соответствующим ASCII
#перевод текста к нужному набору символов
def RecodeToCharset(Text, Charset):
NewText = ''
#если испльзуется еврейский шрифт, еще надо поменять порядок символов
#в строке, потому-чо в utf-8 иврит пишется справа налево
if Charset in HebrewFonts:
Text = Text[::-1]
print Text
for i in xrange(0, len(Text)):
Found = False
for Pair in Charset:
if Pair[0]==Text[i]:
NewText = NewText + Pair[1]
Found = True
if not Found:
NewText = NewText + Text[i]
return NewText
Text='l[a'
print RecodeToCharset(Text, Charsets.BQTHeb)