Hi,

On Fri, Jan 22, 2010 at 3:22 PM, saintthor <[email protected]> wrote:

> for example:
>
> fResult = urlfetch.fetch( "http:...." )
>
> now, fResult.content is "abc还有中文"
>
> how can i encode it into unicode? i have tried:
>
> s = unicode( fResult.content )
> s = fResult.content.decode()
> s = u"%s" % fResult.content
>
> an exception always occur like: UnicodeDecodeError: 'ascii' codec
> can't decode byte 0xc8 in position 3: ordinal not in range(128)
>

You need to know what character set the response body is encoded in. Then
you can call result.content.decode('charset') - eg,
result.content.decode('utf-8').

-Nick Johnson


> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>


-- 
Nick Johnson, Developer Programs Engineer, App Engine
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number:
368047

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to