Changeset 128682 in webkit


Ignore:
Timestamp:
Sep 14, 2012 9:36:06 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

WTFString::show doesn't dump non-ASCII characters in a readable manner
https://bugs.webkit.org/show_bug.cgi?id=96749

Patch by Glenn Adams <glenn@skynav.com> on 2012-09-14
Reviewed by Benjamin Poulain.

Dump non-ASCII characters in a useful form for debugging.

  • wtf/text/WTFString.cpp:

(asciiDebug):
Dump non-ASCII characters (i.e., UTF-16 code elements) as well as non-printable ASCII characters
using \uXXXX format.

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r128657 r128682  
     12012-09-14  Glenn Adams  <glenn@skynav.com>
     2
     3        WTFString::show doesn't dump non-ASCII characters in a readable manner
     4        https://bugs.webkit.org/show_bug.cgi?id=96749
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        Dump non-ASCII characters in a useful form for debugging.
     9
     10        * wtf/text/WTFString.cpp:
     11        (asciiDebug):
     12        Dump non-ASCII characters (i.e., UTF-16 code elements) as well as non-printable ASCII characters
     13        using \uXXXX format.
     14
    1152012-09-14  Alexey Proskuryakov  <ap@apple.com>
    216
  • trunk/Source/WTF/wtf/text/WTFString.cpp

    r128609 r128682  
    2727#include <wtf/ASCIICType.h>
    2828#include <wtf/DataLog.h>
     29#include <wtf/HexNumber.h>
    2930#include <wtf/MathExtras.h>
    3031#include <wtf/MemoryInstrumentation.h>
     
    11361137
    11371138    Vector<char> buffer;
    1138     unsigned length = impl->length();
    1139     const UChar* characters = impl->characters();
    1140 
    1141     buffer.resize(length + 1);
    1142     for (unsigned i = 0; i < length; ++i) {
    1143         UChar ch = characters[i];
    1144         buffer[i] = ch && (ch < 0x20 || ch > 0x7f) ? '?' : ch;
    1145     }
    1146     buffer[length] = '\0';
    1147 
     1139    for (unsigned i = 0; i < impl->length(); ++i) {
     1140        UChar ch = (*impl)[i];
     1141        if (isASCIIPrintable(ch))
     1142            buffer.append(ch);
     1143        else {
     1144            buffer.append('\\');
     1145            buffer.append('u');
     1146            appendUnsignedAsHexFixedSize(ch, buffer, 4);
     1147        }
     1148    }
     1149    buffer.append('\0');
    11481150    return buffer;
    11491151}
Note: See TracChangeset for help on using the changeset viewer.