[Tutor] characters in python

Alan Gauld alan.gauld at btinternet.com
Thu Oct 19 00:16:35 CEST 2006


"Gigs_" <gigs at hi.t-com.hr> wrote in message
> here is the code:

So where do you think you tell Python that you are
using unicode strings?

I'm no expert but I think, as a minimum you need:

for i in S:
  S = S.replace(u'æ', u'ć')
  S = S.replace(u'è', u'č')
  S = S.replace(u'ð', u'đ')

You might also need to specify a locale/encoding,
but I'm not sure about that...

BTW THere is a translate() somewhere function in Python
that might enable you to do all the translations in one step.
You specify a set of characters to translate and the
corresponding translations. Sounds a lot like what you
want - if it works with unicode...

Regards,

Alan G. 




More information about the Tutor mailing list