[pyar] Unicode - BOM

Mariano Reingart reingart en gmail.com
Mie Ene 25 20:38:33 ART 2012


2012/1/25 Mariano Reingart <reingart en gmail.com>

> On Wed, Jan 25, 2012 at 4:13 PM, david weil <tenuki en gmail.com> wrote:
>
>> Hola!
>>
>> Tengo un file que esta grabado en algún UTF y tiene BOM.
>>
>> alguna forma simple de f.read().decode( ? ) ?
>>
>> o tengo que leer el BOM y segun eso decodearlo?
>>
>>
> Quizas esta función unicode_file_read() te sirva:
>
> http://code.google.com/p/rad2py/source/browse/ide2py/fileutil.py#21
>
> Detecta BOM o encoding python, te devuelve unicode según corresponda.
>
>
Me olvidaba, si solo manejas el BOM de utf_8 podrias usar codecs.open con
encodings.utf_8_sig ("utf-8-sig"):

http://docs.python.org/library/codecs.html#module-encodings.utf_8_sig

Sds

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20120125/0c7eeb24/attachment.html>


More information about the pyar mailing list