Newbie problem with codecs

derek / nul abuseonly at sgrail.org
Thu Aug 21 05:23:21 EDT 2003


On Thu, 21 Aug 2003 05:50:23 GMT, "Andrew Dalke" <adalke at mindspring.com> wrote:

>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>)

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 from my program.

I am using www.python.org/doc/lib/module-codecs.html 4.9 codecs -- Codec
registry and base classes   page 1

Do I assume that the codecs module is not working?

Derek




More information about the Python-list mailing list