void MarkupAccumulator::appendCharactersReplacingEntities(StringBuilder& result, const String& source, unsigned offset, unsigned length, EntityMask entityMask) { DEFINE_STATIC_LOCAL(const CString, ampReference, ("&")); DEFINE_STATIC_LOCAL(const CString, ltReference, ("<")); DEFINE_STATIC_LOCAL(const CString, gtReference, (">")); DEFINE_STATIC_LOCAL(const CString, quotReference, (""")); DEFINE_STATIC_LOCAL(const CString, nbspReference, (" ")); static const EntityDescription entityMaps[] = { { '&', ampReference, EntityAmp }, { '<', ltReference, EntityLt }, { '>', gtReference, EntityGt }, { '"', quotReference, EntityQuot }, { noBreakSpace, nbspReference, EntityNbsp }, }; if (!(offset + length)) return; ASSERT(offset + length <= source.length()); if (source.is8Bit()) appendCharactersReplacingEntitiesInternal(result, source.characters8() + offset, length, entityMaps, WTF_ARRAY_LENGTH(entityMaps), entityMask); else appendCharactersReplacingEntitiesInternal(result, source.characters16() + offset, length, entityMaps, WTF_ARRAY_LENGTH(entityMaps), entityMask); }
void MarkupFormatter::appendCharactersReplacingEntities(StringBuilder& result, const String& source, unsigned offset, unsigned length, EntityMask entityMask) { DEFINE_STATIC_LOCAL(const CString, ampReference, ("&")); DEFINE_STATIC_LOCAL(const CString, ltReference, ("<")); DEFINE_STATIC_LOCAL(const CString, gtReference, (">")); DEFINE_STATIC_LOCAL(const CString, quotReference, (""")); DEFINE_STATIC_LOCAL(const CString, nbspReference, (" ")); DEFINE_STATIC_LOCAL(const CString, tabReference, ("	")); DEFINE_STATIC_LOCAL(const CString, lineFeedReference, (" ")); DEFINE_STATIC_LOCAL(const CString, carriageReturnReference, (" ")); static const EntityDescription entityMaps[] = { { '&', ampReference, EntityAmp }, { '<', ltReference, EntityLt }, { '>', gtReference, EntityGt }, { '"', quotReference, EntityQuot }, { noBreakSpaceCharacter, nbspReference, EntityNbsp }, { '\t', tabReference, EntityTab }, { '\n', lineFeedReference, EntityLineFeed }, { '\r', carriageReturnReference, EntityCarriageReturn }, }; if (!(offset + length)) return; DCHECK_LE(offset + length, source.length()); if (source.is8Bit()) appendCharactersReplacingEntitiesInternal(result, source.characters8() + offset, length, entityMaps, WTF_ARRAY_LENGTH(entityMaps), entityMask); else appendCharactersReplacingEntitiesInternal(result, source.characters16() + offset, length, entityMaps, WTF_ARRAY_LENGTH(entityMaps), entityMask); }