My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# coding: utf-8

from django.http import HttpResponse
from django.shortcuts import render_to_response

import datetime

from utils import columnize, rowize, block_firsts, blocks, UnicodeChar

# source for charmaps: http://docs.python.org/_sources/library/codecs.txt
legacy_codes = (
(u'Western Europe',(
'latin1 iso-8859-1 iso8859-1 8859 cp819 latin latin-1 L1',
'cp1140 ibm1140',
'cp1252 windows-1252',
'cp500 EBCDIC-CP-BE EBCDIC-CP-CH IBM500',
'cp850 850 IBM850',
'iso8859_15 iso-8859-15',
'mac_roman macroman',
),),
(u'Arabic',(
'cp1256 windows1256',
'cp864 IBM864',
'iso8859_6 iso-8859-6 arabic',
),),
(u'Baltic languages',(
'cp1257 windows-1257',
'cp775 IBM775',
'iso8859_13 iso-8859-13',
'iso8859_4 iso-8859-4 latin4 L4',
),),
(u'Bulgarian, Byelorussian, Macedonian, Russian, Serbian',(
'cp1251 windows-1251',
'cp855 855 IBM855',
'iso8859_5 iso-8859-5 cyrillic',
'mac_cyrillic maccyrillic',
),),
(u'Canadian',(
'cp863 863 IBM863',
),),
(u'Celtic languages',(
'iso8859_14 iso-8859-14, latin8, L8',
),),
(u'Central and Eastern Europe',(
'cp1250 windows-1250',
'cp852 852 IBM852',
'iso8859_2 iso-8859-2 latin2 L2',
'mac_latin2 maclatin2 maccentraleurope',
),),
(u'Danish, Norwegian',(
'cp865 865 IBM865',
),),
(u'English',(
'ascii iso646 646 us-ascii',
'cp037 IBM037 IBM039',
'cp437 437 IBM437',
),),
(u'Esperanto, Maltese',(
'iso8859_3 iso-8859-3 latin3 L3',
),),
(u'Greek',(
'cp1253 windows-1253',
'cp737',
'cp869 869 CP-GR IBM869',
'cp875',
'iso8859_7 iso-8859-7 greek greek8',
'mac_greek macgreek',
),),
(u'Hebrew',(
'cp1255 windows-1255',
'cp424 EBCDIC-CP-HE IBM424',
'cp856',
'cp862 862 IBM862',
'iso8859_8 iso-8859-8 hebrew',
),),
(u'Icelandic',(
'cp861 861 CP-IS IBM861',
'mac_iceland maciceland',
),),
(u'Nordic languages',(
'iso8859_10 iso-8859-10 latin6 L6',
),),
(u'Portuguese',(
'cp860 860, IBM860',
),),
(u'Russian',(
'cp866 866 IBM866',
'koi8_r',
),),
(u'Thai',(
'cp874',
),),
(u'Turkish',(
'cp1026 ibm1026',
'cp1254 windows-1254',
'cp857 857 IBM857',
'iso8859_9 iso-8859-9 latin5 L5',
'mac_turkish macturkish',
),),
(u'Ukrainian',(
'koi8_u',
),),
(u'Urdu',(
'cp1006',
),),
(u'Vietnamese',(
'cp1258 windows-1258',
),),
)

def main(request):
page_title = u'Unibabel V.1'
block_pages = [dict(title=title, url='/block/%x'%first)
for first, l, title in blocks]
legacy_pages = []
for group_name, pages in legacy_codes:
group = {'name': group_name}
group['pages'] = []
for page in pages:
encodings = page.split()
encoding = encodings[0]
if len(encodings) > 1:
aliases = '(%s)' % ', '.join(encodings[1:])
else:
aliases = ''
group['pages'].append(dict(url='/legacy/%s/'%encoding,
encoding=encoding,
aliases=aliases))
legacy_pages.append(group)
return render_to_response('mainpage.django.html', locals())

COLS = 32

def block_page(request, first):
first = int(first, 16)
last, page_title = block_firsts[first]
scope = ('U+%04x...U+%04x' % (first, last)).upper()
columns = rowize([UnicodeChar(i) for i in xrange(first, last+1)], COLS)
col_heads = ['%x'%(i%0x10) for i in range(COLS)]
return render_to_response('chartable.django.html', locals())

def legacy_page(request, encoding, title, aliases):
page_title = title
first, last = (0x00, 0xFF)
chars = []
for i in xrange(0xFF):
try:
char = ord(chr(i).decode(encoding))
except UnicodeDecodeError:
char = 0
chars.append(char)

columns = rowize([UnicodeChar(i) for i in chars], COLS)
col_heads = ['%x'%(i%0x10) for i in range(COLS)]
return render_to_response('chartable.django.html', locals())

def char_detail(request, codepoint):
char = UnicodeChar(int(codepoint, 16))
return render_to_response('chardetail.django.html', locals())

Change log

8d3a6c65f883 by Luciano Ramalho <luci...@ramalho.org> on Aug 2, 2009   Diff
legacy pages grouped by language
Go to: 
Project members, sign in to write a code review

Older revisions

dafce9081af0 by Luciano Ramalho <luci...@ramalho.org> on Aug 2, 2009   Diff
initial import from propython @
bitbucket
All revisions of this file

File info

Size: 4560 bytes, 160 lines
Powered by Google Project Hosting