Changeset 62449 in webkit for trunk/JavaScriptCore/wtf/text/StringImpl.h
- Timestamp:
- Jul 3, 2010, 1:30:24 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/text/StringImpl.h
r62416 r62449 258 258 } 259 259 260 PassRefPtr<StringImpl> copyStringWithoutBOMs(bool definitelyHasBOMs, bool& hasBOMs) 261 { 262 static const UChar byteOrderMark = 0xFEFF; 263 size_t i = 0; 264 if (!definitelyHasBOMs) { 265 hasBOMs = false; 266 // ECMA-262 calls for stripping all Cf characters, but we only strip BOM characters. 267 // See <https://bugs.webkit.org/show_bug.cgi?id=4931> for details. 268 for (; i < m_length; i++) { 269 if (UNLIKELY(m_data[i] == byteOrderMark)) { 270 hasBOMs = true; 271 break; 272 } 273 } 274 if (!hasBOMs) 275 return this; 276 } 277 Vector<UChar> result; 278 result.reserveInitialCapacity(m_length); 279 size_t firstBOM = i; 280 i = 0; 281 for (; i < firstBOM; i++) 282 result.append(m_data[i]); 283 for (; i < m_length; i++) { 284 UChar c = m_data[i]; 285 if (c != byteOrderMark) 286 result.append(c); 287 } 288 return StringImpl::adopt(result); 289 } 290 260 291 // Returns a StringImpl suitable for use on another thread. 261 292 PassRefPtr<StringImpl> crossThreadString();
Note:
See TracChangeset
for help on using the changeset viewer.