Changeset 65305 in webkit for trunk/JavaScriptCore/wtf/text/WTFString.cpp
- Timestamp:
- Aug 13, 2010, 12:35:45 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/text/WTFString.cpp
r65302 r65305 655 655 } 656 656 657 CString String::utf8( ) const657 CString String::utf8(bool strict) const 658 658 { 659 659 unsigned length = this->length(); … … 673 673 674 674 char* buffer = bufferVector.data(); 675 ConversionResult result = convertUTF16ToUTF8(&characters, characters + length, &buffer, buffer + bufferVector.size(), false); 676 ASSERT(result != sourceIllegal); // Only produced from strict conversion. 675 ConversionResult result = convertUTF16ToUTF8(&characters, characters + length, &buffer, buffer + bufferVector.size(), strict); 677 676 ASSERT(result != targetExhausted); // (length * 3) should be sufficient for any conversion 678 677 679 // If a high surrogate is left unconverted, treat it the same was as an unpaired high surrogate 680 // would have been handled in the middle of a string with non-strict conversion - which is to say, 681 // simply encode it to UTF-8. 678 // Only produced from strict conversion. 679 if (result == sourceIllegal) 680 return CString(); 681 682 // Check for an unconverted high surrogate. 682 683 if (result == sourceExhausted) { 683 // This should be one unpaired high surrogate. 684 if (strict) 685 return CString(); 686 // This should be one unpaired high surrogate. Treat it the same 687 // was as an unpaired high surrogate would have been handled in 688 // the middle of a string with non-strict conversion - which is 689 // to say, simply encode it to UTF-8. 684 690 ASSERT((characters + 1) == (this->characters() + length)); 685 691 ASSERT((*characters >= 0xD800) && (*characters <= 0xDBFF));
Note:
See TracChangeset
for help on using the changeset viewer.