[RFC] string handling in python

Tom Tromey tromey@redhat.com
Mon Jul 7 23:31:00 GMT 2008


>>>>> "Thiago" == Thiago Jung Bauermann <bauerman@br.ibm.com> writes:

Thiago> So, in my opinion for GDB's Python bindings we should always
Thiago> use Unicode strings, and convert to/from desired encodings as
Thiago> necessary. Strings provided by the user would be assumed to
Thiago> have host_charset () encoding, and strings coming from/going
Thiago> to the inferior would be assumed to have target_charset ()
Thiago> encoding.

Sounds reasonable to me.

I thought we already did some of this... search for host_charset in
the python directory.

Thiago> So for example, to create a value object of char * type using
Thiago> a string provided by the user or coming from Python code, GDB
Thiago> would first convert the Python string object (assumed to be in
Thiago> the host charset) to a unicode object (this process is called
Thiago> "decoding", in python parlance), and then convert it from
Thiago> unicode to a string in the target charset.

This sounds like a good candidate for convenience functions, one for
each direction.

Tom



More information about the Gdb mailing list