different encodings for unicode() and u''.encode(), bug?

John Machin sjmachin at lexicon.net
Wed Jan 2 04:44:47 EST 2008


On Jan 2, 7:45 pm, mario <ma... at ruggier.org> wrote:
> On Jan 2, 9:30 am, "Martin v. Löwis" <mar... at v.loewis.de> wrote:
>
> > Use "mbcs" in the second call, not "mcbs".
>
> Ooops, sorry about that, when i switched to test it in the interpreter
> I mistyped "mbcs" with "mcbs". But remark I did it consistently ;-)
> I.e. it was still teh same encoding, even if maybe non-existant.. ?
>
> If I try again using "mbcs" consistently, I still get the same error:
>
> $ python
> Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
> [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.>>> unicode('', 'mbcs')
> u''
> >>> unicode('', 'mbcs').encode('mbcs')
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> LookupError: unknown encoding: mbcs

Two things for you to do:

(1) Try these at the Python interactive prompt:

unicode('', 'latin1')
unicode('', 'mbcs')
unicode('', 'raboof')
unicode('abc', 'latin1')
unicode('abc', 'mbcs')
unicode('abc', 'raboof')

(2) Read what the manual (Library Reference -> codecs module ->
standard encodings) has to say about mbcs.



More information about the Python-list mailing list