Search the web
Sign In
New User? Sign Up
python-list · Python List
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Re: Newbie problem with codecs   Message List  
Reply | Forward Message #106137 of 122067 |
Re: Newbie problem with codecs

derek / nul wrote:
> > File "apply_physics.py", line 12, in ?
> > codecs.lookup(BOM_UTF16_LE)
> > NameError: name 'BOM_UTF16_LE' is not defined

Alex
> Change the statement to:
> codecs.lookup(codecs,BOM_UTF16_LE)

Typo? Shouldn't that be a "." instead of a "."?

In any case

>>> codecs.lookup(codecs.BOM_UTF16_LE)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\PYTHON23\Lib\encodings\__init__.py", line 84, in search_function
globals(), locals(), _import_tail)
ValueError: Empty module name
>>>

In any case, the "BOM" means "byte order marker" and
the constant is the string prefix used to indicate which
UTF16 encoding is used. It isn't the encoding name.

Perhaps the following is what the OP wanted?

>>> codecs.lookup("utf-16-le")
(<built-in function utf_16_le_encode>, <built-in function utf_16_le_decode>,
<class encodings.utf_16_le.StreamReader at 0x01396840>, <class
encodings.utf_16_le.StreamWriter at 0x01396810>)
>>>

But I am not Martin. ;)

Andrew
dalke@...


--
http://mail.python.org/mailman/listinfo/python-list



Thu Aug 21, 2003 12:50 pm

adalke@...
Send Email Send Email

Forward
Message #106137 of 122067 |
Expand Messages Author Sort by Date

derek / nul wrote: ... Change the statement to: codecs.lookup(codecs,BOM_UTF16_LE) Alex -- http://mail.python.org/mailman/listinfo/python-list...
Alex Martelli
aleax@...
Send Email
Aug 21, 2003
5:54 am

... Alex ... Typo? Shouldn't that be a "." instead of a "."? In any case ... Traceback (most recent call last): File "<interactive input>", line 1, in ? File...
Andrew Dalke
adalke@...
Send Email
Aug 21, 2003
5:57 am

Andrew Dalke wrote: ... A dot, not a comma -- sorry, the font I use makes them hard to tell apart (at least w/my failing eyesight) and they're right next to...
Alex Martelli
aleax@...
Send Email
Aug 21, 2003
6:38 am

... Andrew, this what I was expecting, but my system does not do it. codecs.lookup("utf-16-le") this is the code cut from my program, but there is NO output...
derek / nul
abuseonly@...
Send Email
Aug 21, 2003
9:27 am

... program. I barely know what I am doing, and given that you don't report what you mean by "does not do it" nor "NO output from my program" makes it hard to...
Andrew Dalke
adalke@...
Send Email
Aug 21, 2003
10:13 am

... Very close, I want to read a utf16le into memory, convert to text, change 100 lines in the file, convert back to utf16le and write back to disk. ... My...
derek / nul
abuseonly@...
Send Email
Aug 22, 2003
5:52 am

derek / nul ... of ... How does it fail? It may be because print tries to convert the data as appropriate for your IDE or terminal, and fails. Eg, the ...
Andrew Dalke
adalke@...
Send Email
Aug 22, 2003
7:52 am

... File "apply_physics.py", line 21, in ? print t File "C:\Program Files\Python\lib\encodings\cp850.py", line 18, in encode return...
derek / nul
abuseonly@...
Send Email
Aug 22, 2003
8:13 am

... encode ... position ... I don't know enough to handle this problem. Anyone else care to try? Andrew dalke@... -- ...
Andrew Dalke
adalke@...
Send Email
Aug 22, 2003
8:23 am

... Andrew, I am not concerned about that problem. I need a pointer to converting utf-16-le to text Derek -- ...
derek / nul
abuseonly@...
Send Email
Aug 22, 2003
8:28 am

"derek / nul" <abuseonly@...> wrote in message news:mkabkvkguslj36n1qd1gsot8hbvh5qm321@.... ... 100 ... file ... of ... If there is a BOM, then it...
Mike Brown
mike-nospam@...
Send Email
Aug 22, 2003
5:48 pm

... This paragraph is from http://www.egenix.com/files/python/unicode-proposal.txt It explains the difference between utf-16-le and utf-16-be ... Standard...
derek / nul
abuseonly@...
Send Email
Aug 23, 2003
12:58 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help