Giorgio, 03.03.2010 14:09:
  byte_string = unicode_string.encode('utf-8')

If you use unicode strings throughout your application, you will be happy
with the above. Note that this is an advice, not a condition.

Mmm ok. So all strings in the app are unicode by default?

Do you know if there is a function/method i can use to check encoding of a
string?

Not sure what exactly you mean here. If you meant to say "guess the encoding of a byte string", then there are a few ways to do that. But none of them is guaranteed to work. Therefore my advice: use unicode everywhere and decode byte strings on the way in, where you (hopefully) know their encoding. If you don't know the encoding on the way in, reject the input.

Stefan

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

Reply via email to