Changeset 65344 in webkit for trunk/JavaScriptCore/wtf/text/WTFString.cpp
- Timestamp:
- Aug 13, 2010, 6:28:27 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/text/WTFString.cpp
r65305 r65344 613 613 } 614 614 615 Vector<char> String::ascii() const 616 { 617 if (m_impl) 618 return m_impl->ascii(); 619 620 const char* nullMsg = "(null impl)"; 621 Vector<char, 2048> buffer; 622 for (int i = 0; nullMsg[i]; ++i) 623 buffer.append(nullMsg[i]); 624 625 buffer.append('\0'); 626 return buffer; 627 } 628 629 CString String::latin1() const 615 CString String::ascii() const 630 616 { 631 617 // Basic Latin1 (ISO) encoding - Unicode characters 0..255 are … … 640 626 for (unsigned i = 0; i < length; ++i) { 641 627 UChar ch = characters[i]; 642 characterBuffer[i] = ch > 255 ? '?' : ch; 628 characterBuffer[i] = ch && (ch < 0x20 || ch > 0x7f) ? '?' : ch; 629 } 630 631 return result; 632 } 633 634 CString String::latin1() const 635 { 636 // Basic Latin1 (ISO) encoding - Unicode characters 0..255 are 637 // preserved, characters outside of this range are converted to '?'. 638 639 unsigned length = this->length(); 640 const UChar* characters = this->characters(); 641 642 char* characterBuffer; 643 CString result = CString::newUninitialized(length, characterBuffer); 644 645 for (unsigned i = 0; i < length; ++i) { 646 UChar ch = characters[i]; 647 characterBuffer[i] = ch > 0xff ? '?' : ch; 643 648 } 644 649
Note:
See TracChangeset
for help on using the changeset viewer.