[Qt-interest] QString::size()

Atlant Schmidt aschmidt at dekaresearch.com
Fri Sep 2 13:33:17 CEST 2011


Nandita:

> ...however was perplexed about the sentence.

  So because QStrings aren't CStrings but are instead counted UTF16
  characters, the '\0' character has no special meaning within them.
  As a result, it can be embedded anywhere within the string just
  like any other UTF16 character.

                                                        Atlant

From: nandita-a.mehta at nokia.com [mailto:nandita-a.mehta at nokia.com]
Sent: Friday, September 02, 2011 07:30
To: Atlant Schmidt
Cc: qt-interest at qt.nokia.com
Subject: RE: QString::size()

Atlant:


Wanted to clarify the statement "A QString can embed '\0' characters (QChar::Null<http://doc.qt.nokia.com/latest/qchar.html#SpecialCharacter-enum>). The size<http://doc.qt.nokia.com/latest/qstring.html#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<http://doc.qt.nokia.com/latest/qchar.html#SpecialCharacter-enum>). The size<http://doc.qt.nokia.com/latest/qstring.html#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<https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg==> 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.

________________________________
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110902/62a105a0/attachment.html 


More information about the Qt-interest-old mailing list