Qt 4.8
Functions
qdeclarativeparser.cpp File Reference
#include "private/qdeclarativeparser_p.h"
#include "qdeclarativepropertyvaluesource.h"
#include "private/qdeclarativevme_p.h"
#include "qdeclarative.h"
#include "private/qdeclarativecomponent_p.h"
#include "qdeclarativecomponent.h"
#include "private/qmetaobjectbuilder_p.h"
#include "private/qdeclarativevmemetaobject_p.h"
#include "private/qdeclarativecompiler_p.h"
#include "parser/qdeclarativejsast_p.h"
#include "parser/qdeclarativejsengine_p.h"
#include <QStack>
#include <QColor>
#include <QPointF>
#include <QSizeF>
#include <QRectF>
#include <QStringBuilder>
#include <QtDebug>

Go to the source code of this file.

Functions

QString escapedString (const QString &string)
 

Function Documentation

◆ escapedString()

QString escapedString ( const QString string)

Definition at line 321 of file qdeclarativeparser.cpp.

Referenced by QDeclarativeParser::Variant::asScript().

322 {
323  QString tmp = QLatin1String("\"");
324  for (int i = 0; i < string.length(); ++i) {
325  const QChar &c = string.at(i);
326  switch(c.unicode()) {
327  case 0x08:
328  tmp += QLatin1String("\\b");
329  break;
330  case 0x09:
331  tmp += QLatin1String("\\t");
332  break;
333  case 0x0A:
334  tmp += QLatin1String("\\n");
335  break;
336  case 0x0B:
337  tmp += QLatin1String("\\v");
338  break;
339  case 0x0C:
340  tmp += QLatin1String("\\f");
341  break;
342  case 0x0D:
343  tmp += QLatin1String("\\r");
344  break;
345  case 0x22:
346  tmp += QLatin1String("\\\"");
347  break;
348  case 0x27:
349  tmp += QLatin1String("\\\'");
350  break;
351  case 0x5C:
352  tmp += QLatin1String("\\\\");
353  break;
354  default:
355  tmp += c;
356  break;
357  }
358  }
359  tmp += QLatin1Char('\"');
360  return tmp;
361 }
unsigned char c[8]
Definition: qnumeric_p.h:62
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55