MCPcopy Create free account
hub / github.com/avast/retdec / toWide

Function toWide

src/utils/string.cpp:398–410  ·  view source on GitHub ↗

* @brief Converts @a str to wide string. * * @param[in] str String for conversion. * @param[in] length Length in bytes of one character in output string. * If length is zero, function returns empty string. * * @return Converted string. */

Source from the content-addressed store, hash-verified

396* @return Converted string.
397*/
398std::string toWide(const std::string &str, std::string::size_type length) {
399 if (!length) {
400 return "";
401 }
402
403 const std::string padding(length - 1, '\0');
404 std::string result;
405 result.reserve(str.length() * length);
406 for (auto c : str) {
407 result += c + padding;
408 }
409 return result;
410}
411
412/**
413* @brief Converts unicode @a bytes to ASCII string.

Callers 2

pe_heuristics.cppFile · 0.85
TEST_FFunction · 0.85

Calls 1

lengthMethod · 0.80

Tested by 1

TEST_FFunction · 0.68