std::string EncodeImpl(string_view raw,  // UTF8
                       std::function<bool(int)> should_encode) {
  const char kHex[] = "0123456789ABCDEF";

  std::string encoded;

  for (auto i = raw.begin(); i != raw.end(); ++i) {
    // For UTF8 encoded string, char ASCII can be greater than 127.
    // Cast to unsigned char firstly to make sure it's in [0,255].
    int c = static_cast<unsigned char>(*i);

    if (should_encode(c)) {
      encoded.push_back('%');
      encoded.push_back(kHex[(c >> 4) & 0xF]);
      encoded.push_back(kHex[c & 0xF]);
    } else {
      encoded.push_back(static_cast<char>(c));
    }
  }

  return encoded;
}
std::string EncodeImpl(string_view raw,   
                       std::function<bool(int)> should_encode) {
  const char kHex[] = "0123456789ABCDEF";

  std::string encoded;

  for (auto i = raw.begin(); i != raw.end(); ++i) {
     
     
    int c = static_cast<unsigned char>(*i);

    if (should_encode(c)) {
      encoded.push_back('%');
      encoded.push_back(kHex[(c >> 4) & 0xF]);
      encoded.push_back(kHex[c & 0xF]);
    } else {
      encoded.push_back(static_cast<char>(c));
    }
  }

  return encoded;
}