summaryrefslogtreecommitdiff
path: root/qmake/tools/qtextstream.cpp
Side-by-side diff
Diffstat (limited to 'qmake/tools/qtextstream.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/tools/qtextstream.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/qmake/tools/qtextstream.cpp b/qmake/tools/qtextstream.cpp
index 75c6531..ddca5bd 100644
--- a/qmake/tools/qtextstream.cpp
+++ b/qmake/tools/qtextstream.cpp
@@ -964,257 +964,257 @@ void QTextStream::ts_putc( QChar c )
QString s = c;
QCString block = d->encoder->fromUnicode( s, len );
dev->writeBlock( block, len );
} else
#endif
if ( latin1 ) {
if ( c.row() )
dev->putch( '?' ); // unknown character
else
dev->putch( c.cell() );
} else {
if ( doUnicodeHeader ) {
doUnicodeHeader = FALSE;
ts_putc( QChar::byteOrderMark );
}
if ( internalOrder ) {
// this case is needed by QStringBuffer
dev->writeBlock( (char*)&c, sizeof(QChar) );
} else if ( networkOrder ) {
dev->putch( c.row() );
dev->putch( c.cell() );
} else {
dev->putch( c.cell() );
dev->putch( c.row() );
}
}
}
/*!
Puts one character into the stream.
*/
void QTextStream::ts_putc( int ch )
{
ts_putc( QChar((ushort)ch) );
}
bool QTextStream::ts_isdigit( QChar c )
{
return c.isDigit();
}
bool QTextStream::ts_isspace( QChar c )
{
return c.isSpace();
}
void QTextStream::ts_ungetc( QChar c )
{
if ( c.unicode() == 0xffff )
return;
d->ungetcBuf.prepend( c );
}
/*!
Reads \a len bytes from the stream into \a s and returns a
reference to the stream.
The buffer \a s must be preallocated.
Note that no encoding is done by this function.
\warning The behavior of this function is undefined unless the
stream's encoding is set to Unicode or Latin1.
\sa QIODevice::readBlock()
*/
QTextStream &QTextStream::readRawBytes( char *s, uint len )
{
dev->readBlock( s, len );
return *this;
}
/*!
Writes the \a len bytes from \a s to the stream and returns a
reference to the stream.
Note that no encoding is done by this function.
\sa QIODevice::writeBlock()
*/
QTextStream &QTextStream::writeRawBytes( const char* s, uint len )
{
dev->writeBlock( s, len );
return *this;
}
QTextStream &QTextStream::writeBlock( const char* p, uint len )
{
if ( doUnicodeHeader ) {
doUnicodeHeader = FALSE;
if ( !mapper && !latin1 )
ts_putc( QChar::byteOrderMark );
}
// QCString and const char * are treated as Latin-1
if ( !mapper && latin1 ) {
dev->writeBlock( p, len );
} else if ( !mapper && internalOrder ) {
QChar *u = new QChar[len];
for ( uint i = 0; i < len; i++ )
u[i] = p[i];
dev->writeBlock( (char*)u, len * sizeof(QChar) );
delete [] u;
} else {
for ( uint i = 0; i < len; i++ )
ts_putc( (uchar)p[i] );
}
return *this;
}
QTextStream &QTextStream::writeBlock( const QChar* p, uint len )
{
#ifndef QT_NO_TEXTCODEC
if ( mapper ) {
if ( !d->encoder )
d->encoder = mapper->makeEncoder();
QConstString s( p, len );
int l = len;
QCString block = d->encoder->fromUnicode( s.string(), l );
dev->writeBlock( block, l );
} else
#endif
if ( latin1 ) {
- char *str = QString::unicodeToAscii( p, len );
+ char *str = QString::unicodeToLatin1( p, len );
dev->writeBlock( str, len );
delete [] str;
} else if ( internalOrder ) {
if ( doUnicodeHeader ) {
doUnicodeHeader = FALSE;
ts_putc( QChar::byteOrderMark );
}
dev->writeBlock( (char*)p, sizeof(QChar)*len );
} else {
for (uint i=0; i<len; i++)
ts_putc( p[i] );
}
return *this;
}
/*!
Resets the text stream.
\list
\i All flags are set to 0.
\i The field width is set to 0.
\i The fill character is set to ' ' (Space).
\i The precision is set to 6.
\endlist
\sa setf(), width(), fill(), precision()
*/
void QTextStream::reset()
{
fflags = 0;
fwidth = 0;
fillchar = ' ';
fprec = 6;
}
/*!
\fn QIODevice *QTextStream::device() const
Returns the IO device currently set.
\sa setDevice(), unsetDevice()
*/
/*!
Sets the IO device to \a iod.
\sa device(), unsetDevice()
*/
void QTextStream::setDevice( QIODevice *iod )
{
if ( owndev ) {
delete dev;
owndev = FALSE;
}
dev = iod;
d->sourceType = QTextStreamPrivate::IODevice;
}
/*!
Unsets the IO device. Equivalent to setDevice( 0 ).
\sa device(), setDevice()
*/
void QTextStream::unsetDevice()
{
setDevice( 0 );
d->sourceType = QTextStreamPrivate::NotSet;
}
/*!
\fn bool QTextStream::atEnd() const
Returns TRUE if the IO device has reached the end position (end of
the stream or file) or if there is no IO device set; otherwise
returns FALSE.
\sa QIODevice::atEnd()
*/
/*!\fn bool QTextStream::eof() const
\obsolete
This function has been renamed to atEnd().
\sa QIODevice::atEnd()
*/
/*****************************************************************************
QTextStream read functions
*****************************************************************************/
/*!
\overload
Reads a char \a c from the stream and returns a reference to the
stream. Note that whitespace is skipped.
*/
QTextStream &QTextStream::operator>>( char &c )
{
CHECK_STREAM_PRECOND
c = eat_ws();
return *this;
}
/*!
Reads a char \a c from the stream and returns a reference to the
stream. Note that whitespace is \e not skipped.
*/
QTextStream &QTextStream::operator>>( QChar &c )
{
CHECK_STREAM_PRECOND
c = ts_getc();
return *this;
}
ulong QTextStream::input_bin()
{
ulong val = 0;
QChar ch = eat_ws();
int dv = ch.digitValue();