[Qt-interest] QString::size()

Jason H scorp1us at yahoo.com
Fri Sep 2 17:36:06 CEST 2011


Microsoft likes to use the:

this\0
is\0
a\0
list\0
\0 <- zero length string indicating end of list

trick to give a list where only a string exists in the api.



________________________________
From: "nandita-a.mehta at nokia.com" <nandita-a.mehta at nokia.com>
To: aschmidt at dekaresearch.com
Cc: qt-interest at qt.nokia.com
Sent: Friday, September 2, 2011 7:30 AM
Subject: Re: [Qt-interest] QString::size()


 
Atlant:
 
Wanted to clarify the statement “A QString can embed '\0' characters (QChar::Null). The size() function always returns the size of the whole string, including embedded '\0' characters.“
in the document.
Even I understood that QString does not require ‘\0’ however was perplexed about the sentence.
 
Nandita
 
From:ext Atlant Schmidt [mailto:aschmidt at dekaresearch.com] 
Sent: Friday, September 02, 2011 4:56 PM
To: Mehta Nandita-A (Nokia-SD/Bangalore); qt-interest at qt.nokia.com
Subject: RE: QString::size()
 
Nandita:
 
> And I was expecting the output as 6 (including ‘\0’) but it is 5.
> QString str14 = "Apple";
> qDebug()<<str14.size();  //5
 
  What ‘\0’ character? ;-)

  QStrings aren’t CStrings; they’re counted collections of UTF16 characters
  and don’t require any trailing ‘\0’ character to end them. So that string
  only contains 5 UTF16 characters.
 
                                             Atlant
 
 
From:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com [mailto:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] On Behalf Of nandita-a.mehta at nokia.com
Sent: Friday, September 02, 2011 04:15
To: qt-interest at qt.nokia.com
Subject: [Qt-interest] QString::size()
 
Hi,
 
In the documentation (http://doc.qt.nokia.com/latest/qstring.html) it is mentioned that 
“A QString can embed '\0' characters (QChar::Null). The size() function always returns the size of the whole string, including embedded '\0' characters.“
And I was expecting the output as 6 (including ‘\0’) but it is 5.
QString str14 = "Apple";
qDebug()<<str14.size();  //5
 
 
Any clarification on what does the above sentence in the documentation?
 
And I thought that is the difference between QString::size() and QString::length(). But not
qDebug()<<str14.length(); //5
 
Thank You.
 
Regards,
Nandita
 
 
Click here to report this email as spam.
 

________________________________
 
This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.

Thank you.

Please consider the environment before printing this email.
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110902/03bf654d/attachment.html 


More information about the Qt-interest-old mailing list