[Development] Deprecating QString::{v,}sprintf()

Marc Mutz marc.mutz at kdab.com
Tue Feb 21 18:28:44 CET 2012

On Tuesday February 21 2012, Marc Mutz wrote:
> On Tuesday February 21 2012, you wrote:
> > On Tue, Feb 21, 2012 at 3:20 PM,  <jan-arve.saether at nokia.com> wrote:
> > > Is there any reason why we cannot move QString::asprintf() to
> > > QByteArray::asprintf() instead?
> >
> > If your data is already in a QString, you're going to pay a rather
> > large penalty to copy it all to a byte array just to use that, and
> > then convert it back.
> That's exactly what QString::sprintf does right now - it only works on 8bit
> strings, even though it stores the result in a QString.

It does use QLocale methods for formatting, and it supports the l modifier 
to %s. For a port to QByteArray, we'd need to define what encoding to assume 
(QString expects utf-8 on input, and we'd keep that, but we need to decide 
which encoding to _output_).


Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions

More information about the Development mailing list