MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / DecodeHex

Function DecodeHex

common/StringUtil.cpp:181–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179 }
180
181 std::optional<std::vector<u8>> DecodeHex(const std::string_view in)
182 {
183 std::vector<u8> data;
184 data.reserve(in.size() / 2);
185
186 for (size_t i = 0; i < in.size() / 2; i++)
187 {
188 std::optional<u8> byte = StringUtil::FromChars<u8>(in.substr(i * 2, 2), 16);
189 if (byte.has_value())
190 data.push_back(*byte);
191 else
192 return std::nullopt;
193 }
194
195 return {data};
196 }
197
198 std::string EncodeHex(const u8* data, int length)
199 {

Callers 1

patchMethod · 0.85

Calls 4

substrMethod · 0.80
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected