Convert a Hex value string to an ASCII Text String
I'm surprised that, according to your code, C++ doesn't have a strip_prefix or without_beginning or skip_start function to skip over the initial "0x". If there were one, you should definitely use that instead of implementing your own. Do a little search, I'm sure such a function exists.

Even though this is C++, there is no need to write a class for a simple conversion function like this. In my experience, this task can be solved in less than 20 lines of code, and there is no state that you need to save between method calls, therefore a class is unnecessary. Just write an ordinary std::string hex_to_bytes(const std::string_view &amp;hex) function.

As far as I remember, std::string has a push_back method, therefore there's no need to use an intermediate vector for building up the string.

My rough idea is:

std::string hex_to_bytes(const std::string_view &amp;hex) {
    std::size_t i = 0, size = hex.size();
    if (size &gt;= 2 &amp;&amp; hex[0] == '0' &amp;&amp; hex[1] == 'x')
        i += 2;

    std::string result;
    for (; i + 1 &lt; size; i += 2) {
        char octet_chars[] = { hex[i], hex[i + 1], '\0' };

        char *end;
        unsigned long octet = std::strtoul(octet_chars, &amp;end, 16);
        if (end != octet_chars + 2)
            throw std::some_exception();

        result.push_back(static_cast&lt;char&gt;(octet));
    }

    if (i != size)
        throw std::some_exception();

    return result;
}


I didn't test the above code.
It also doesn't look very C++-like to me because it accesses the character array directly. But probably, for this kind of functions, there is no high-level way of expressing the code.



By the way, instead of writing all this code, you could also write a Perl one-liner:

perl -pe '$_ = pack("H*", $1) if /([0-9a-f]+)/i'