MCPcopy Create free account
hub / github.com/catboost/catboost / Escape

Method Escape

library/cpp/testing/unittest/junit.cpp:564–595  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

562 }
563
564 void Escape(const TStringBuf str) {
565 const unsigned char* i = reinterpret_cast<const unsigned char*>(str.data());
566 const unsigned char* end = i + str.size();
567 while (i < end) {
568 wchar32 rune;
569 size_t runeLen;
570 const RECODE_RESULT result = SafeReadUTF8Char(rune, runeLen, i, end);
571 if (result == RECODE_OK) { // string is expected not to have unallowed characters now
572 switch (rune) {
573 case '\'':
574 Out.Write("&apos;");
575 break;
576 case '\"':
577 Out.Write("&quot;");
578 break;
579 case '<':
580 Out.Write("&lt;");
581 break;
582 case '>':
583 Out.Write("&gt;");
584 break;
585 case '&':
586 Out.Write("&amp;");
587 break;
588 default:
589 Out.Write(i, runeLen);
590 break;
591 }
592 i += runeLen;
593 }
594 }
595 }
596
597private:
598 TFileOutput Out;

Callers 3

TTagClass · 0.45
StartMethod · 0.45
EndMethod · 0.45

Calls 4

SafeReadUTF8CharFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected