void BlobBuilder::append(const String& text, const String& endingType) { CString utf8Text = UTF8Encoding().encode(text.characters(), text.length(), EntitiesForUnencodables); Vector<char>& buffer = getBuffer(); size_t oldSize = buffer.size(); if (endingType == "native") normalizeLineEndingsToNative(utf8Text, buffer); else { ASSERT(endingType == "transparent"); buffer.append(utf8Text.data(), utf8Text.length()); } m_size += buffer.size() - oldSize; }
void BlobBuilder::append(const String& text, const String& endingType, ExceptionCode& ec) { bool isEndingTypeTransparent = endingType == "transparent"; bool isEndingTypeNative = endingType == "native"; if (!endingType.isEmpty() && !isEndingTypeTransparent && !isEndingTypeNative) { ec = SYNTAX_ERR; return; } CString utf8Text = UTF8Encoding().encode(text.characters(), text.length(), EntitiesForUnencodables); Vector<char>& buffer = getBuffer(); size_t oldSize = buffer.size(); if (isEndingTypeNative) normalizeLineEndingsToNative(utf8Text, buffer); else buffer.append(utf8Text.data(), utf8Text.length()); m_size += buffer.size() - oldSize; }