This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Printing of strings with special characters
Hello Tom,
for my example string 'höhö' this code works for me, the 'ö' character
is number 246 in ASCII. I will start with some testing routines in the
next days.
best regards
Tom Tromey schrieb:
>>>>>> "Anton" == Anton Kunze <ak@technosis.de> writes:
>>>>>>
>
> Anton> http://websvn.kde.org/trunk/extragear/sdk/kdevelop/debuggers/gdb/printers/
>
> Also, the QStringPrinter code seems suspect to me:
>
> class QStringPrinter:
>
> def __init__(self, val):
> self.val = val
>
> def to_string(self):
> ret = ""
> i = 0
> while i < self.val['d']['size']:
> if self.val['d']['data'][i] > 256:
> #TODO: fix this properly
> ret += '?'
> else:
> ret += chr(self.val['d']['data'][i])
> i = i + 1
> return ret
>
> This is constructing a string by hand, and using '?' to replace some
> characters.
>
> It is better to use Value.string or Value.lazy_string. From the
> qstring.h in code search, I gather that this is UTF-16-encoded, so this
> should probably read:
>
> return self.val['d']['data'].string(encoding = 'UTF-16', length = self.val['d']['size'])
>
> ... though I have never really used Qt, so take with a grain of salt.
>
> Use lazy_string if you have a newer gdb.
>
> Tom
>
>
>
--
Anton Kunze
Entwicklung
_____________________________
Technosis GmbH
Kattrepelsbrücke 1
20095 Hamburg
Tel. +49 - (0)40-33 44 1990
Fax +49 - (0)40-33 44 1999
eMail: ak@technosis.de
_____________________________
Supporthotline: +49-(0)40-3344-1991
Support-eMail: support@technosis.de
Technosis GmbH, Geschäftsführer: Heiko Gerdau, Tobias Dittmar, Dierk
Rathjen, Sitz Hamburg; HRB 89145 Amtsgericht Hamburg