[Interest] QFile::size() and QTextStream::pos()

Thiago Macieira thiago.macieira at intel.com
Wed Oct 28 20:50:47 CET 2015


On Wednesday 28 October 2015 22:37:06 Igor Mironchik wrote:
> Hi,
> 
> Can I expect that values returned by QFile::size() and
> QTextStream::pos() are equal when stream at end?

It should be, but...

> Or pos() of text stream can be smaller then size of file because, for
> example, text stream uses 2 bytes for each character?

The documentation says "Returns the device position corresponding to the 
current position of the stream", so it should account for the codec 
transformations.

But since it's doing conversions along the way, there may be trouble.

Why do you want to know this? Your question screams of the X-Y problem to me.

> Do I understand right that QTextStream::skipWhiteSpace() skips '_' and
> '*' too?

You can easily test this...

> "bool QChar::isSpace() const
> Returns true if the character is a separator character (Separator_*
> categories or certain code points from Other_Control category);
> otherwise returns false."

002A;ASTERISK;Po;0;ON;;;;;N;;;;;
002D;HYPHEN-MINUS;Pd;0;ES;;;;;N;;;;;

Both have categories starting with P (Punctuation), so they're not Separator 
and they're not Other_Control.

Why do you think '*' and '_' should be considered whitespace? They're not even 
blank...

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list