}
-static int m_unprintableBase = 8;
+static int m_unprintableBase = -1;
void WatchHandler::setUnprintableBase(int base)
{
{
if (WatchHandler::unprintableBase() == 0)
return str;
+
QString encoded;
+ if (WatchHandler::unprintableBase() == -1) {
+ foreach (const QChar c, str) {
+ int u = c.unicode();
+ if (u >= 32 && u < 127)
+ encoded += c;
+ else if (u == '\r')
+ encoded += "\\r";
+ else if (u == '\t')
+ encoded += "\\t";
+ else if (u == '\n')
+ encoded += "\\n";
+ else
+ encoded += QString("\\%1")
+ .arg(c.unicode(), 3, 8, QLatin1Char('0'));
+ }
+ return encoded;
+ }
+
foreach (const QChar c, str) {
if (c.isPrint()) {
encoded += c;
QAction *clearTypeFormatAction = 0;
QAction *clearIndividualFormatAction = 0;
QAction *showUnprintableUnicode = 0;
+ QAction *showUnprintableEscape = 0;
QAction *showUnprintableOctal = 0;
QAction *showUnprintableHexadecimal = 0;
formatMenu.setTitle(tr("Change Display Format..."));
formatMenu.addAction(tr("Treat All Characters as Printable"));
showUnprintableUnicode->setCheckable(true);
showUnprintableUnicode->setChecked(unprintableBase == 0);
+ showUnprintableEscape =
+ formatMenu.addAction(tr("Show Unprintable Characters as Escape Sequences"));
+ showUnprintableEscape->setCheckable(true);
+ showUnprintableEscape->setChecked(unprintableBase == -1);
showUnprintableOctal =
formatMenu.addAction(tr("Show Unprintable Characters as Octal"));
showUnprintableOctal->setCheckable(true);
debuggerCore()->openTextEditor(tr("Locals & Watchers"), contents);
} else if (act == showUnprintableUnicode) {
handler->setUnprintableBase(0);
+ } else if (act == showUnprintableEscape) {
+ handler->setUnprintableBase(-1);
} else if (act == showUnprintableOctal) {
handler->setUnprintableBase(8);
} else if (act == showUnprintableHexadecimal) {
void testQString()
{
+ QString str1("Hello Qt"); // --> Value: "Hello Qt"
+ QString str2("Hello\nQt"); // --> Value: ""Hello\nQt"" (double quote not expected)
+ QString str3("Hello\rQt"); // --> Value: ""HelloQt"" (double quote and missing \r not expected)
+ QString str4("Hello\tQt"); // --> Value: "Hello\9Qt" (expected \t instead of \9)
+
QString str = "Hello ";
str += " big, ";
str += "\t";