MCPcopy Create free account
hub / github.com/Icinga/icinga2 / ValidateUTF8

Method ValidateUTF8

lib/base/utility.cpp:1798–1810  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1796const char l_Utf8Replacement[] = "\xEF\xBF\xBD";
1797
1798String Utility::ValidateUTF8(const String& input)
1799{
1800 std::string output;
1801 output.reserve(input.GetLength());
1802
1803 try {
1804 utf8::replace_invalid(input.Begin(), input.End(), std::back_inserter(output));
1805 } catch (const utf8::not_enough_room&) {
1806 output.insert(output.end(), (const char*)l_Utf8Replacement, (const char*)l_Utf8Replacement + 3);
1807 }
1808
1809 return String(std::move(output));
1810}
1811
1812#ifdef _WIN32
1813/* mkstemp extracted from libc/sysdeps/posix/tempname.c. Copyright

Callers

nothing calls this directly

Calls 7

StringClass · 0.70
replace_invalidFunction · 0.50
GetLengthMethod · 0.45
BeginMethod · 0.45
EndMethod · 0.45
insertMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected