pb with xmlrpclib

Alexandre Fayolle Alexandre.Fayolle at logilab.fr
Fri Jul 6 10:20:38 EDT 2001


On Fri, 6 Jul 2001, Skip Montanaro wrote:

> 
>     Alexandre> If I use the default server, the following call causes an
>     Alexandre> error on the server:
> 
>     ... print server.echo('\231')
> 
>     Alexandre> Is this a bug in xmlrpc or in the underlying xmllib ?
> 
> Neither, I think.  The default encoding for XML is utf-8, not latin-1.  In
> addition, XMLRPC only supports ASCII.  

Well, maybe, but xmlrpclib says that is supports unicode strings in
arguments. 

> Try
> 
>     server.echo('a')

This obviously works, but it's not what I'm asking about. 

However I get this \231 character from elsewhere (some webpage, actually),
and I need to get a way to pass it around. Using 
      server.echo(unicode('\231','latin-1').encode('utf-8'))
dies not help either.

If I test with a loop such as 
for a in range(256):
    print a,'%c'%a
    try:
        print repr(server.echo(unicode('%c'%a,'latin-1').encode('utf-8')))
    except Error, v:
        print "ERROR", v

I get errors for chars in range (decimal) 0-8,11-12,14-31,127-159,192-223. 

For range 0-8,11-12,14-31 I can understand that there might be a problem
somewhere, because these are controle characters. For range 127-159, I can
understand, because the chars are left undefined in latin-1, but 192-223
are valid latin-1 characters as far as I know (capital accentuated letters
mainly).


Alexandre Fayolle
-- 
LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
Narval, the first software agent available as free software (GPL).







More information about the Python-list mailing list