can compile function have a bug?

Y

ygao

compile('U"ÖÐ"','c:/test','single')

why is the result different?
a bug or another reason?
 
P

Peter Otten

ygao said:
why is the result different?
a bug or another reason?

How that particular output came to be I don't know, but you should be able
to avoid the confusion by either passing a unicode string to compile() or
specifying the encoding:
u'\u4e2d'

Peter

PS: In and all-UTF-8 environment I would have /expected/ to see
u'\xe4\xb8\xad'

and that's indeed what I get over here:
u'\xe4\xb8\xad'
 
J

John Machin

Peter said:
How that particular output came to be I don't know, but you should be able
to avoid the confusion by either passing a unicode string to compile() or
specifying the encoding:

u'\u4e2d'

Peter

PS: In and all-UTF-8 environment I would have /expected/ to see

u'\xe4\xb8\xad'

and that's indeed what I get over here:

u'\xe4\xb8\xad'

But it's not an all-UTF-8 environment; his_encoding = 'gb2312' or one
of its heirs/successors :)

Cheers,
John
 
P

Peter Otten

John said:
But it's not an all-UTF-8 environment; his_encoding = 'gb2312' or one
of its heirs/successors :)

Ouch. Almost understanding a problem hurts more than not understanding it at
all. I just had a refresher of the experience...

Peter
 
Y

ygao

Peter said:
How that particular output came to be I don't know, but you should be able
to avoid the confusion by either passing a unicode string to compile() or
specifying the encoding:

u'\u4e2d'
this is what I want!
many thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top