This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: [RFC] string handling in python
- From: Tom Tromey <tromey at redhat dot com>
- To: Thiago Jung Bauermann <bauerman at br dot ibm dot com>
- Cc: gdb ml <gdb at sourceware dot org>
- Date: Mon, 07 Jul 2008 17:30:46 -0600
- Subject: Re: [RFC] string handling in python
- References: <1215408302.1795.38.camel@localhost.localdomain>
- Reply-to: tromey at redhat dot com
>>>>> "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