[Qt-interest] Interaction between QApplication and swscanf
Thiago Macieira
thiago.macieira at trolltech.com
Thu Sep 10 11:39:54 CEST 2009
Em Quinta-feira 10. Setembro 2009, às 12.19.48, você escreveu:
> I have strange behaviour with the swscanf function in my QT programs : This
> function always returns 0 when a QApplication is declared ...
> float val;
>
> wchar_t wStr[] = L"0.98";
>
> swscanf( wStr, L"%f", &val );
>
> return val;
>
> }
The reason is that QApplication calls setlocale(3). That changes your libc's
locale (so that the system produces proper locale strings and translated
messages).
That also means your decimal separator changed from . to ,
You should use a function that is locale-independent if you're parsing locale-
independent data.
--
Thiago Macieira - thiago.macieira (AT) nokia.com
Senior Product Manager - Nokia, Qt Development Frameworks
Sandakerveien 116, NO-0402 Oslo, Norway
Qt Developer Days 2009 | Registration Now Open!
Munich, Germany: Oct 12 - 14 San Francisco, California: Nov 2 - 4
http://qt.nokia.com/qtdevdays2009
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090910/6d99abd3/attachment.bin
More information about the Qt-interest-old
mailing list