*/
/*! \internal
- Note: The len contains the ending \0
*/
void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out)
{
#ifndef QT_NO_TEXTCODEC
if (QString::codecForCStrings && len) {
- QString tmp = QString::fromAscii(a, len > 0 ? len - 1 : -1);
+ QString tmp = QString::fromAscii(a, len > 0 ? len : -1);
memcpy(out, reinterpret_cast<const char *>(tmp.constData()), sizeof(QChar) * tmp.size());
out += tmp.length();
return;
while (*a)
*out++ = QLatin1Char(*a++);
} else {
- for (int i = 0; i < len - 1; ++i)
+ for (int i = 0; i < len; ++i)
*out++ = QLatin1Char(a[i]);
}
}
#ifndef QT_NO_CAST_FROM_ASCII
static inline void QT_ASCII_CAST_WARN appendTo(const char a[N], QChar *&out)
{
- QAbstractConcatenable::convertFromAscii(a, N, out);
+ QAbstractConcatenable::convertFromAscii(a, N - 1, out);
}
#endif
static inline void appendTo(const char a[N], char *&out)
#ifndef QT_NO_CAST_FROM_ASCII
static inline void QT_ASCII_CAST_WARN appendTo(const char a[N], QChar *&out)
{
- QAbstractConcatenable::convertFromAscii(a, N, out);
+ QAbstractConcatenable::convertFromAscii(a, N - 1, out);
}
#endif
static inline void appendTo(const char a[N], char *&out)
enum { ExactSize = false };
static int size(const QByteArray &ba) { return ba.size(); }
#ifndef QT_NO_CAST_FROM_ASCII
- static inline void appendTo(const QByteArray &ba, QChar *&out)
+ static inline QT_ASCII_CAST_WARN void appendTo(const QByteArray &ba, QChar *&out)
{
- // adding 1 because convertFromAscii expects the size including the null-termination
- QAbstractConcatenable::convertFromAscii(ba.constData(), ba.size() + 1, out);
+ QAbstractConcatenable::convertFromAscii(ba.constData(), ba.size(), out);
}
#endif
static inline void appendTo(const QByteArray &ba, char *&out)
#ifndef QT_NO_CAST_FROM_ASCII
static inline QT_ASCII_CAST_WARN void appendTo(const type &a, QChar *&out)
{
- // adding 1 because convertFromAscii expects the size including the null-termination
- QAbstractConcatenable::convertFromAscii(a.ptr->data, N + 1, out);
+ QAbstractConcatenable::convertFromAscii(a.ptr->data, N, out);
}
#endif
static inline void appendTo(const type &ba, char *&out)