How to print a unicode string?

Ben Finney bignose+hates-spam at benfinney.id.au
Fri Apr 18 19:51:48 EDT 2008


damonwischik at gmail.com writes:

> From what I've googled, I think I need to set my locale. I don't
> understand how.
> 
> import locale
> print locale.getlocale()
> --> (None,None)
> print locale.getdefaultlocal()
> --> ('en_GB','cp1252')
> print locale.normalize('en_GB.utf-8')
> --> en_GB.UTF8
> locale.setlocale(locale.LC_ALL,'en_GB.UTF8')
> -->  locale.Error: unsupported locale setting
> 
> I'd be grateful for advice.

Just because the locale library knows the normalised name for it
doesn't mean it's available on your OS. Have you confirmed that your
OS (independent of Python) supports the locale you're trying to set?

-- 
 \           "Oh, I love your magazine. My favorite section is 'How To |
  `\          Increase Your Word Power'. That thing is really, really, |
_o__)                       really... good."  -- Homer, _The Simpsons_ |
Ben Finney



More information about the Python-list mailing list