Giorgio wrote:
2010/3/7 spir <denis.s...@gmail.com>

One more question: Amazon SimpleDB only accepts UTF8.

So, let's say i have to put into an image file:

Do you mean a binary file with image data, such as a jpeg? In that case, an emphatic - NO. not even close.
filestream = file.read()
filetoput = filestream.encode('utf-8')

Do you think this is ok?

Oh, of course everything url-encoded then

Giorgio


Encoding binary data with utf-8 wouldn't make any sense, even if you did have the right semantics for a text file. Next problem, 'file' is a built-in keyword. So if you write what you describe, you're trying to call a non-static function with a class object, which will error.


Those two lines don't make any sense by themselves. Show us some context, and we can more sensibly comment on them. And try not to use names that hide built-in keywords, or Python stdlib names.

If you're trying to store binary data in a repository that only permits text, it's not enough to pretend to convert it to UTF-8. You need to do some other escaping, such as UUENCODE, that transforms the binary data into something resembling text. Then you may or may not need to encode that text with utf-8, depending on its character set.


DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to