MCPcopy Create free account
hub / github.com/GameTechDev/PresentMon / ToNarrow

Function ToNarrow

IntelPresentMon/CommonUtilities/str/String.cpp:55–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 }
54
55 std::string ToNarrow(const std::wstring& wide) noexcept
56 {
57 try {
58 std::string narrow;
59 // TODO: replace with resize_and_overwrite when it becomes widely available
60 narrow.resize(wide.size() * 2);
61 const auto actual = WideCharToMultiByte(CP_UTF8, 0, wide.data(), (int)wide.size(),
62 narrow.data(), (int)narrow.size(), nullptr, nullptr);
63 if (actual > 0) {
64 narrow.resize(actual);
65 return narrow;
66 }
67 // TODO: (maybe) check for insufficient buffer error and do redo with two-pass (or just double buffer again)
68 pmlog_error("failed conversion to narrow").hr();
69 }
70 catch (...) {
71 pmlog_error(ReportException());
72 }
73 return {};
74 }
75
76 template<class S>
77 S TrimWhitespace(const S& input)

Callers 15

HandlePclEventMethod · 0.85
GetCpuNameMethod · 0.85
IndicateMethod · 0.85
GetMethod · 0.85
RegistryMethod · 0.85
MakeRandomNameMethod · 0.85
EtwLogSessionMethod · 0.85
InvalidParameterHandler_Function · 0.85
ExecuteOnRendererMethod · 0.85
InvalidParameterHandler_Function · 0.85

Calls 2

ReportExceptionFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected