string.encode on HP-UX
Michael Hudson
mwh at python.net
Wed Jul 21 09:12:56 EDT 2004
Richard Townsend <richardt at edshk.demon.co.uk> writes:
> 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')
>
> produces:
>
> locale = C C C C C C
> locale = roman8
> Traceback (most recent call last):
> File "test_locale.py", 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?
What is roman8? If it's some hp-ux specific thingy, I guess the
solution is to teach Python what to do with it. If it's just HP's
name for iso-8859-1 or something then this is easy (mucking with
encodings.aliases).
If it's some custom encoding, finding out what unicode codepoint each
octet maps to and writing a codec a la macroman can't be impossibly
hard.
I guess a patch would be welcome either way.
Cheers,
mwh
--
Windows 2000: Smaller cow. Just as much crap.
-- Jim's pedigree of operating systems, asr
More information about the Python-list
mailing list