Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39581
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: encoding error in python 27 |
| Date | 2013-02-22 16:40 +0100 |
| Organization | None |
| References | <a3d3d352-c170-4165-9552-741869106830@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2276.1361547628.2939.python-list@python.org> (permalink) |
Hala Gamal wrote:
> my code works well with english file but when i use text file
> encodede"utf-8" "my file contain some arabic letters" it doesn't work. my
> code:
> with codecs.open("tt.txt",encoding='utf-8') as txtfile:
Try encoding="utf-8-sig" in the above to remove the byte order mark (BOM)
upon decoding, see
http://docs.python.org/2.7/library/codecs.html#module-encodings.utf_8_sig
That should prevent
> UnicodeEncodeError: 'decimal' codec can't encode character u'\ufeff' in
> position 0: invalid decimal Unicode string
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
encoding error in python 27 Hala Gamal <halagamal2009@gmail.com> - 2013-02-22 06:55 -0800
Re: encoding error in python 27 Peter Otten <__peter__@web.de> - 2013-02-22 16:40 +0100
Re: encoding error in python 27 MRAB <python@mrabarnett.plus.com> - 2013-02-22 17:35 +0000
Re: encoding error in python 27 Hala Gamal <halagamal2009@gmail.com> - 2013-02-23 20:31 -0800
Re: encoding error in python 27 Peter Otten <__peter__@web.de> - 2013-02-24 09:34 +0100
csiph-web