#include #include #include #include #include #include #include #include #include using namespace std; int main(int argc, char **argv) { /** * in Hex : 7f 20 48 65 6c 6c 6f 20 62 6f 62 * * */ char pattern[] = { 127, 32, 72, 101, 108, 108, 111, 32, 98, 111, 98}; std::cout << "--------------------- RAW PATTERN --------------------" << endl; fprintf(stdout, "INFO: pattern to be checked raw: \"%s\"\n", pattern); hs_database_t *database; // Printing char array elements in decimal value for (int i =0; i < strlen(pattern); i++) { int a = pattern[i]; std::cout << a << " " ; } std::cout << endl;; //End Printing std::vector keyArray; std::vector flagArray; std::vector idArray; hs_compile_error_t *perror; keyArray.push_back(pattern); idArray.push_back(1); flagArray.assign(keyArray.size(), HS_FLAG_DOTALL | HS_FLAG_UTF8 | HS_FLAG_CASELESS); hs_error_t error = hs_compile_multi(keyArray.data(), flagArray.data(), idArray.data(), keyArray.size(), HS_MODE_BLOCK, NULL, &database, &perror); if (error != HS_SUCCESS) { std::cout << " error happened: " << perror->message << std::endl; } else { std::cout << " success: " << error << std::endl; } bool valid = ue2::isValidUtf8(pattern, strlen(pattern)); std::cout << " is valid: " << valid << std::endl; return 0; }