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

Thiago Macieira thiago.macieira at intel.com
Tue Feb 21 19:00:17 CET 2012


On terça-feira, 21 de fevereiro de 2012 18.28.44, Marc Mutz wrote:
> 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_).

Do you mean for the following code?

	QString().sprintf("%ls", otherqstring.utf16())

I didn't know that was possible until you mentioned it. I doubt many people 
are using it. Note that it's also different from the real printf's %ls, which 
expects wchar_t*, not ushort*.

Changing to QByteArray would mean assuming an encoding *if* we keep our own 
code. I'd much rather this used vasprintf and let the system deal with it. (In 
that case, wide strings would be converted using an equivalent of 
toLocal8Bit()).

This is a source of subtle bugs, so I'm going to drop the proposal. Just make 
the functions static and we'll work on a proper C++11 replacement later.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120221/81af61cb/attachment.sig>


More information about the Development mailing list