From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15136 invoked by alias); 9 Mar 2010 07:54:55 -0000 Received: (qmail 15109 invoked by uid 22791); 9 Mar 2010 07:54:53 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from wp151.webpack.hosteurope.de (HELO wp151.webpack.hosteurope.de) (80.237.132.158) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 09 Mar 2010 07:54:49 +0000 Received: from 188-192-228-236-dynip.superkabel.de ([188.192.228.236] helo=[192.168.1.130]); authenticated by wp151.webpack.hosteurope.de running ExIM with esmtpa id 1NouH9-0008P3-E3; Tue, 09 Mar 2010 08:54:47 +0100 Message-ID: <4B95FEC2.8020500@technosis.de> Date: Tue, 09 Mar 2010 07:54:00 -0000 From: Anton Kunze User-Agent: Thunderbird 2.0.0.18 (X11/20081112) MIME-Version: 1.0 To: Tom Tromey CC: gdb@sourceware.org Subject: Re: Printing of strings with special characters References: <4B8F9FE9.2040401@technosis.de> <4B90C17B.8020001@technosis.de> <4B94BC31.3020109@technosis.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00055.txt.bz2 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 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