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

Function charToHexaStringRepr

src/utils/string.cpp:140–146  ·  view source on GitHub ↗

* @brief Converts the given character into a hexadecimal representation to be * used in escaped C strings. * * @param[in] c Character to be converted. * @param[in] charSize How large is actually the character in @a c (in bits)? * * For example, @c ';' is converted into @c "\x3b" when @c charSize is 8. */

Source from the content-addressed store, hash-verified

138* For example, @c ';' is converted into @c "\x3b" when @c charSize is 8.
139*/
140std::string charToHexaStringRepr(WideCharType c, std::size_t charSize) {
141 std::stringstream stringRepr;
142 stringRepr << "\\x"
143 << std::setfill('0') << std::setw(widthOf(charSize))
144 << std::hex << c;
145 return stringRepr.str();
146}
147
148/**
149* @brief Can the given character be appended literally, i.e. without escaping

Callers 1

charToEscapedCStringReprFunction · 0.85

Calls 2

widthOfFunction · 0.85
strMethod · 0.80

Tested by

no test coverage detected