43
43
__codec_error_registry__ = {}
44
44
45
45
46
+ @__builtin__
46
47
def register (search_function ):
47
48
if not __codec_search_path__ :
48
49
__codec_registry_init__ ()
@@ -56,6 +57,7 @@ def __normalizestring(string):
56
57
return string .replace (' ' , '-' ).lower ()
57
58
58
59
60
+ @__builtin__
59
61
def lookup (encoding ):
60
62
if not __codec_search_path__ :
61
63
__codec_registry_init__ ()
@@ -99,6 +101,7 @@ def __decoder(encoding):
99
101
return __codec_getitem (encoding , 1 )
100
102
101
103
104
+ @__builtin__
102
105
def encode (obj , encoding = 'utf-8' , errors = 'strict' ):
103
106
encoder = __encoder (encoding )
104
107
if encoder :
@@ -108,6 +111,7 @@ def encode(obj, encoding='utf-8', errors='strict'):
108
111
return result [0 ]
109
112
110
113
114
+ @__builtin__
111
115
def decode (obj , encoding = 'utf-8' , errors = 'strict' ):
112
116
decoder = __decoder (encoding )
113
117
if decoder :
@@ -117,12 +121,14 @@ def decode(obj, encoding='utf-8', errors='strict'):
117
121
return result [0 ]
118
122
119
123
124
+ @__builtin__
120
125
def register_error (errors , handler ):
121
126
if not hasattr (handler , '__call__' ):
122
127
raise TypeError ('handler must be callable' )
123
128
__codec_error_registry__ [errors ] = handler
124
129
125
130
131
+ @__builtin__
126
132
def lookup_error (errors = 'strict' ):
127
133
handler = __codec_error_registry__ .get (errors )
128
134
if handler is None :
@@ -139,201 +145,201 @@ def __codec_registry_init__():
139
145
140
146
141
147
# TODO implement the encode / decode methods
142
- @staticmethod
148
+ @__builtin__
143
149
def escape_encode (data , errors = None ):
144
150
raise NotImplementedError ()
145
151
146
152
147
- @staticmethod
153
+ @__builtin__
148
154
def escape_decode (data , errors = None ):
149
155
raise NotImplementedError ()
150
156
151
157
152
- @staticmethod
158
+ @__builtin__
153
159
def utf_8_encode (string , errors = None ):
154
160
return __truffle_encode (string , "utf-8" , errors )
155
161
156
162
157
- @staticmethod
163
+ @__builtin__
158
164
def utf_8_decode (string , errors = None , final = False ):
159
165
return __truffle_decode (string , "utf-8" , errors )
160
166
161
167
162
- @staticmethod
168
+ @__builtin__
163
169
def utf_7_encode (string , errors = None ):
164
170
return __truffle_encode (string , "utf-7" , errors )
165
171
166
172
167
- @staticmethod
173
+ @__builtin__
168
174
def utf_7_decode (string , errors = None , final = False ):
169
175
return __truffle_decode (string , "utf-7" , errors )
170
176
171
177
172
- @staticmethod
178
+ @__builtin__
173
179
def utf_16_encode (string , errors = None , byteorder = 0 ):
174
180
return __truffle_encode (string , "utf-16" , errors )
175
181
176
182
177
- @staticmethod
183
+ @__builtin__
178
184
def utf_16_decode (string , errors = None , final = False ):
179
185
return __truffle_decode (string , "utf-16" , errors )
180
186
181
187
182
- @staticmethod
188
+ @__builtin__
183
189
def utf_16_le_encode (string , errors = None ):
184
190
return __truffle_encode (string , "utf-16-le" , errors )
185
191
186
192
187
- @staticmethod
193
+ @__builtin__
188
194
def utf_16_le_decode (string , errors = None , final = False ):
189
195
return __truffle_decode (string , "utf-16-le" , errors )
190
196
191
197
192
- @staticmethod
198
+ @__builtin__
193
199
def utf_16_be_encode (string , errors = None ):
194
200
return __truffle_encode (string , "utf-16-be" , errors )
195
201
196
202
197
- @staticmethod
203
+ @__builtin__
198
204
def utf_16_be_decode (string , errors = None , final = False ):
199
205
return __truffle_decode (string , "utf-16-be" , errors )
200
206
201
207
202
- @staticmethod
208
+ @__builtin__
203
209
def utf_16_ex_decode (data , errors = None , byteorder = 0 , final = False ):
204
210
raise NotImplementedError ()
205
211
206
212
207
- @staticmethod
213
+ @__builtin__
208
214
def utf_32_encode (string , errors = None , byteorder = 0 ):
209
215
return __truffle_encode (string , "utf-32" , errors )
210
216
211
217
212
- @staticmethod
218
+ @__builtin__
213
219
def utf_32_decode (string , errors = None , final = False ):
214
220
return __truffle_decode (string , "utf-32" , errors )
215
221
216
222
217
- @staticmethod
223
+ @__builtin__
218
224
def utf_32_le_encode (string , errors = None ):
219
225
return __truffle_encode (string , "utf-32-le" , errors )
220
226
221
227
222
- @staticmethod
228
+ @__builtin__
223
229
def utf_32_le_decode (string , errors = None , final = False ):
224
230
return __truffle_decode (string , "utf-32-le" , errors )
225
231
226
232
227
- @staticmethod
233
+ @__builtin__
228
234
def utf_32_be_encode (string , errors = None ):
229
235
return __truffle_encode (string , "utf-32-be" , errors )
230
236
231
237
232
- @staticmethod
238
+ @__builtin__
233
239
def utf_32_be_decode (string , errors = None , final = False ):
234
240
return __truffle_decode (string , "utf-32-be" , errors )
235
241
236
242
237
- @staticmethod
243
+ @__builtin__
238
244
def utf_32_ex_decode (data , errors = None , byteorder = 0 , final = False ):
239
245
raise NotImplementedError ()
240
246
241
247
242
- @staticmethod
248
+ @__builtin__
243
249
def unicode_escape_encode (string , errors = None ):
244
250
raise NotImplementedError ()
245
251
246
252
247
- @staticmethod
253
+ @__builtin__
248
254
def unicode_escape_decode (string , errors = None ):
249
255
raise NotImplementedError ()
250
256
251
257
252
- @staticmethod
258
+ @__builtin__
253
259
def unicode_internal_encode (obj , errors = None ):
254
260
raise NotImplementedError ()
255
261
256
262
257
- @staticmethod
263
+ @__builtin__
258
264
def unicode_internal_decode (obj , errors = None ):
259
265
raise NotImplementedError ()
260
266
261
267
262
- @staticmethod
268
+ @__builtin__
263
269
def raw_unicode_escape_encode (string , errors = None ):
264
270
raise NotImplementedError ()
265
271
266
272
267
- @staticmethod
273
+ @__builtin__
268
274
def raw_unicode_escape_decode (string , errors = None ):
269
275
raise NotImplementedError ()
270
276
271
277
272
- @staticmethod
278
+ @__builtin__
273
279
def latin_1_encode (string , errors = None ):
274
280
return __truffle_encode (string , "latin-1" , errors )
275
281
276
282
277
- @staticmethod
283
+ @__builtin__
278
284
def latin_1_decode (string , errors = None ):
279
285
return __truffle_decode (string , "latin-1" , errors )
280
286
281
287
282
- @staticmethod
288
+ @__builtin__
283
289
def ascii_encode (string , errors = None ):
284
290
return __truffle_encode (string , "ascii" , errors )
285
291
286
292
287
- @staticmethod
293
+ @__builtin__
288
294
def ascii_decode (string , errors = None ):
289
295
return __truffle_decode (string , "ascii" , errors )
290
296
291
297
292
- @staticmethod
298
+ @__builtin__
293
299
def charmap_encode (string , errors = None , mapping = None ):
294
300
raise NotImplementedError ()
295
301
296
302
297
- @staticmethod
303
+ @__builtin__
298
304
def charmap_decode (string , errors = None , mapping = None ):
299
305
raise NotImplementedError ()
300
306
301
307
302
- @staticmethod
308
+ @__builtin__
303
309
def charmap_build (mapping ):
304
310
raise NotImplementedError ()
305
311
306
312
307
- @staticmethod
313
+ @__builtin__
308
314
def readbuffer_encode (data , errors = None ):
309
315
raise NotImplementedError ()
310
316
311
317
312
- @staticmethod
318
+ @__builtin__
313
319
def mbcs_encode (string , errors = None ):
314
320
raise NotImplementedError ()
315
321
316
322
317
- @staticmethod
323
+ @__builtin__
318
324
def mbcs_decode (string , errors = None , final = False ):
319
325
raise NotImplementedError ()
320
326
321
327
322
- @staticmethod
328
+ @__builtin__
323
329
def oem_encode (string , errors ):
324
330
raise NotImplementedError ()
325
331
326
332
327
- @staticmethod
333
+ @__builtin__
328
334
def oem_decode (string , errors = None , final = False ):
329
335
raise NotImplementedError ()
330
336
331
337
332
- @staticmethod
338
+ @__builtin__
333
339
def code_page_encode (code_page , string , errors = None ):
334
340
raise NotImplementedError ()
335
341
336
342
337
- @staticmethod
343
+ @__builtin__
338
344
def code_page_decode (code_page , string , errors = None , final = False ):
339
345
raise NotImplementedError ()
0 commit comments