string.encode on HP-UX

Richard Townsend richardt at
Wed Jul 21 12:48:04 CEST 2004

Using Python-2.3.4 on HP-UX11i, the following code:

  import locale
  loc = locale.setlocale(locale.LC_ALL)
  print 'locale =', loc
  loc = locale.nl_langinfo(locale.CODESET)
  print 'locale =', loc
  print 'hello'.encode(loc, 'replace')


  locale = C C C C C C
  locale = roman8
  Traceback (most recent call last):
    File "", line 13, in ?
      print 'hello'.encode(loc, 'replace')
  LookupError: unknown encoding: roman8

[The same code on SUSE 9.1 doesn't raise an exception].

Should I be able to pass the value returned by nl_langinfo() to the
string.encode call?

Similar code is used by wxGlade and this exception prevents it from

Does anybody know how to fix this on HP-UX?

Richard Townsend

More information about the Python-list mailing list