Remove SpdyHexEncode, SpdyHexDecode, Http2HexEncode, Http2HexDecode.

I'll clean up includes and dependences in a subsequent CL when removing
spdy_string_utils and http2_string_utils.

PiperOrigin-RevId: 369197788
Change-Id: I0864351553ca7f26df7286aa97636038b98fefee
diff --git a/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc b/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc
index 6c6a977..b7a8b39 100644
--- a/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc
+++ b/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc
@@ -8,6 +8,7 @@
 
 #include <initializer_list>
 
+#include "absl/strings/escaping.h"
 #include "http2/platform/api/http2_logging.h"
 #include "http2/platform/api/http2_string_utils.h"
 #include "http2/platform/api/http2_test_helpers.h"
@@ -151,7 +152,7 @@
 }
 
 TEST_F(HpackDecoderStringBufferTest, HuffmanWhole) {
-  std::string encoded = Http2HexDecode("f1e3c2e5f23a6ba0ab90f4ff");
+  std::string encoded = absl::HexStringToBytes("f1e3c2e5f23a6ba0ab90f4ff");
   absl::string_view decoded("www.example.com");
 
   EXPECT_EQ(state(), State::RESET);
@@ -176,7 +177,7 @@
 }
 
 TEST_F(HpackDecoderStringBufferTest, HuffmanSplit) {
-  std::string encoded = Http2HexDecode("f1e3c2e5f23a6ba0ab90f4ff");
+  std::string encoded = absl::HexStringToBytes("f1e3c2e5f23a6ba0ab90f4ff");
   std::string part1 = encoded.substr(0, 5);
   std::string part2 = encoded.substr(5);
   absl::string_view decoded("www.example.com");
@@ -215,7 +216,7 @@
 
 TEST_F(HpackDecoderStringBufferTest, InvalidHuffmanOnData) {
   // Explicitly encode the End-of-String symbol, a no-no.
-  std::string encoded = Http2HexDecode("ffffffff");
+  std::string encoded = absl::HexStringToBytes("ffffffff");
 
   buf_.OnStart(/*huffman_encoded*/ true, encoded.size());
   EXPECT_EQ(state(), State::COLLECTING);
@@ -229,7 +230,7 @@
 
 TEST_F(HpackDecoderStringBufferTest, InvalidHuffmanOnEnd) {
   // Last byte of string doesn't end with prefix of End-of-String symbol.
-  std::string encoded = Http2HexDecode("00");
+  std::string encoded = absl::HexStringToBytes("00");
 
   buf_.OnStart(/*huffman_encoded*/ true, encoded.size());
   EXPECT_EQ(state(), State::COLLECTING);
diff --git a/http2/hpack/huffman/hpack_huffman_decoder_test.cc b/http2/hpack/huffman/hpack_huffman_decoder_test.cc
index fa88038..e7a346e 100644
--- a/http2/hpack/huffman/hpack_huffman_decoder_test.cc
+++ b/http2/hpack/huffman/hpack_huffman_decoder_test.cc
@@ -9,6 +9,7 @@
 #include <iostream>
 
 #include "absl/base/macros.h"
+#include "absl/strings/escaping.h"
 #include "http2/decoder/decode_buffer.h"
 #include "http2/decoder/decode_status.h"
 #include "http2/platform/api/http2_string_utils.h"
@@ -188,13 +189,13 @@
 TEST_F(HpackHuffmanDecoderTest, SpecRequestExamples) {
   HpackHuffmanDecoder decoder;
   std::string test_table[] = {
-      Http2HexDecode("f1e3c2e5f23a6ba0ab90f4ff"),
+      absl::HexStringToBytes("f1e3c2e5f23a6ba0ab90f4ff"),
       "www.example.com",
-      Http2HexDecode("a8eb10649cbf"),
+      absl::HexStringToBytes("a8eb10649cbf"),
       "no-cache",
-      Http2HexDecode("25a849e95ba97d7f"),
+      absl::HexStringToBytes("25a849e95ba97d7f"),
       "custom-key",
-      Http2HexDecode("25a849e95bb8e8b4bf"),
+      absl::HexStringToBytes("25a849e95bb8e8b4bf"),
       "custom-value",
   };
   for (size_t i = 0; i != ABSL_ARRAYSIZE(test_table); i += 2) {
@@ -212,17 +213,17 @@
   HpackHuffmanDecoder decoder;
   // clang-format off
   std::string test_table[] = {
-    Http2HexDecode("6402"),
+    absl::HexStringToBytes("6402"),
     "302",
-    Http2HexDecode("aec3771a4b"),
+    absl::HexStringToBytes("aec3771a4b"),
     "private",
-    Http2HexDecode("d07abe941054d444a8200595040b8166"
+    absl::HexStringToBytes("d07abe941054d444a8200595040b8166"
             "e082a62d1bff"),
     "Mon, 21 Oct 2013 20:13:21 GMT",
-    Http2HexDecode("9d29ad171863c78f0b97c8e9ae82ae43"
+    absl::HexStringToBytes("9d29ad171863c78f0b97c8e9ae82ae43"
             "d3"),
     "https://www.example.com",
-    Http2HexDecode("94e7821dd7f2e6c7b335dfdfcd5b3960"
+    absl::HexStringToBytes("94e7821dd7f2e6c7b335dfdfcd5b3960"
             "d5af27087f3672c1ab270fb5291f9587"
             "316065c003ed4ee5b1063d5007"),
     "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1",
diff --git a/http2/hpack/huffman/hpack_huffman_encoder_test.cc b/http2/hpack/huffman/hpack_huffman_encoder_test.cc
index 666fe95..0d32187 100644
--- a/http2/hpack/huffman/hpack_huffman_encoder_test.cc
+++ b/http2/hpack/huffman/hpack_huffman_encoder_test.cc
@@ -5,6 +5,7 @@
 #include "http2/hpack/huffman/hpack_huffman_encoder.h"
 
 #include "absl/base/macros.h"
+#include "absl/strings/escaping.h"
 #include "http2/platform/api/http2_string_utils.h"
 #include "common/platform/api/quiche_test.h"
 
@@ -40,13 +41,13 @@
 
 TEST_P(HuffmanEncoderTest, SpecRequestExamples) {
   std::string test_table[] = {
-      Http2HexDecode("f1e3c2e5f23a6ba0ab90f4ff"),
+      absl::HexStringToBytes("f1e3c2e5f23a6ba0ab90f4ff"),
       "www.example.com",
-      Http2HexDecode("a8eb10649cbf"),
+      absl::HexStringToBytes("a8eb10649cbf"),
       "no-cache",
-      Http2HexDecode("25a849e95ba97d7f"),
+      absl::HexStringToBytes("25a849e95ba97d7f"),
       "custom-key",
-      Http2HexDecode("25a849e95bb8e8b4bf"),
+      absl::HexStringToBytes("25a849e95bb8e8b4bf"),
       "custom-value",
   };
   for (size_t i = 0; i != ABSL_ARRAYSIZE(test_table); i += 2) {
@@ -64,17 +65,17 @@
 TEST_P(HuffmanEncoderTest, SpecResponseExamples) {
   // clang-format off
   std::string test_table[] = {
-    Http2HexDecode("6402"),
+    absl::HexStringToBytes("6402"),
     "302",
-    Http2HexDecode("aec3771a4b"),
+    absl::HexStringToBytes("aec3771a4b"),
     "private",
-    Http2HexDecode("d07abe941054d444a8200595040b8166"
+    absl::HexStringToBytes("d07abe941054d444a8200595040b8166"
             "e082a62d1bff"),
     "Mon, 21 Oct 2013 20:13:21 GMT",
-    Http2HexDecode("9d29ad171863c78f0b97c8e9ae82ae43"
+    absl::HexStringToBytes("9d29ad171863c78f0b97c8e9ae82ae43"
             "d3"),
     "https://www.example.com",
-    Http2HexDecode("94e7821dd7f2e6c7b335dfdfcd5b3960"
+    absl::HexStringToBytes("94e7821dd7f2e6c7b335dfdfcd5b3960"
             "d5af27087f3672c1ab270fb5291f9587"
             "316065c003ed4ee5b1063d5007"),
     "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1",
@@ -120,11 +121,11 @@
   size_t encoded_size = HuffmanSize("foo");
   std::string buffer;
   Encode("foo", encoded_size, &buffer);
-  EXPECT_EQ(Http2HexDecode("94e7"), buffer);
+  EXPECT_EQ(absl::HexStringToBytes("94e7"), buffer);
 
   encoded_size = HuffmanSize("bar");
   Encode("bar", encoded_size, &buffer);
-  EXPECT_EQ(Http2HexDecode("94e78c767f"), buffer);
+  EXPECT_EQ(absl::HexStringToBytes("94e78c767f"), buffer);
 }
 
 }  // namespace
diff --git a/http2/hpack/tools/hpack_block_builder_test.cc b/http2/hpack/tools/hpack_block_builder_test.cc
index d4eb3d7..3821127 100644
--- a/http2/hpack/tools/hpack_block_builder_test.cc
+++ b/http2/hpack/tools/hpack_block_builder_test.cc
@@ -4,6 +4,7 @@
 
 #include "http2/hpack/tools/hpack_block_builder.h"
 
+#include "absl/strings/escaping.h"
 #include "http2/platform/api/http2_string_utils.h"
 #include "common/platform/api/quiche_test.h"
 
@@ -97,7 +98,7 @@
     // 0x0010:  2e63 6f6d                                .com
 
     const std::string expected =
-        Http2HexDecode("828684410f7777772e6578616d706c652e636f6d");
+        absl::HexStringToBytes("828684410f7777772e6578616d706c652e636f6d");
     EXPECT_EQ(expected, b.buffer());
   }
 }
@@ -128,7 +129,7 @@
     // 0x0010:  ff                                       .
 
     const std::string expected =
-        Http2HexDecode("828684418cf1e3c2e5f23a6ba0ab90f4ff");
+        absl::HexStringToBytes("828684418cf1e3c2e5f23a6ba0ab90f4ff");
     EXPECT_EQ(expected, b.buffer());
   }
 }
diff --git a/http2/hpack/tools/hpack_example.cc b/http2/hpack/tools/hpack_example.cc
index 00664b2..b2783e3 100644
--- a/http2/hpack/tools/hpack_example.cc
+++ b/http2/hpack/tools/hpack_example.cc
@@ -6,6 +6,7 @@
 
 #include <ctype.h>
 
+#include "absl/strings/escaping.h"
 #include "absl/strings/str_cat.h"
 #include "http2/platform/api/http2_bug_tracker.h"
 #include "http2/platform/api/http2_logging.h"
@@ -22,7 +23,7 @@
       QUICHE_CHECK_GT(example.size(), 1u) << "Truncated hex byte?";
       const char c1 = example[1];
       QUICHE_CHECK(isxdigit(c1)) << "Found half a byte?";
-      *output += Http2HexDecode(example.substr(0, 2));
+      *output += absl::HexStringToBytes(example.substr(0, 2));
       example.remove_prefix(2);
       continue;
     }
diff --git a/http2/hpack/varint/hpack_varint_decoder_test.cc b/http2/hpack/varint/hpack_varint_decoder_test.cc
index 3d73c5c..a67cca6 100644
--- a/http2/hpack/varint/hpack_varint_decoder_test.cc
+++ b/http2/hpack/varint/hpack_varint_decoder_test.cc
@@ -9,6 +9,7 @@
 #include <stddef.h>
 
 #include "absl/base/macros.h"
+#include "absl/strings/escaping.h"
 #include "absl/strings/string_view.h"
 #include "http2/platform/api/http2_logging.h"
 #include "http2/platform/api/http2_string_utils.h"
@@ -28,7 +29,7 @@
  protected:
   HpackVarintDecoderTest()
       : high_bits_(::testing::get<0>(GetParam())),
-        suffix_(Http2HexDecode(::testing::get<1>(GetParam()))),
+        suffix_(absl::HexStringToBytes(::testing::get<1>(GetParam()))),
         prefix_length_(0) {}
 
   void DecodeExpectSuccess(absl::string_view data,
@@ -261,7 +262,7 @@
 
 TEST_P(HpackVarintDecoderTest, Success) {
   for (size_t i = 0; i < ABSL_ARRAYSIZE(kSuccessTestData); ++i) {
-    DecodeExpectSuccess(Http2HexDecode(kSuccessTestData[i].data),
+    DecodeExpectSuccess(absl::HexStringToBytes(kSuccessTestData[i].data),
                         kSuccessTestData[i].prefix_length,
                         kSuccessTestData[i].expected_value);
   }
@@ -302,7 +303,7 @@
 
 TEST_P(HpackVarintDecoderTest, Error) {
   for (size_t i = 0; i < ABSL_ARRAYSIZE(kErrorTestData); ++i) {
-    DecodeExpectError(Http2HexDecode(kErrorTestData[i].data),
+    DecodeExpectError(absl::HexStringToBytes(kErrorTestData[i].data),
                       kErrorTestData[i].prefix_length);
   }
 }
diff --git a/http2/hpack/varint/hpack_varint_encoder_test.cc b/http2/hpack/varint/hpack_varint_encoder_test.cc
index cd1666b..7f049e8 100644
--- a/http2/hpack/varint/hpack_varint_encoder_test.cc
+++ b/http2/hpack/varint/hpack_varint_encoder_test.cc
@@ -5,8 +5,8 @@
 #include "http2/hpack/varint/hpack_varint_encoder.h"
 
 #include "absl/base/macros.h"
+#include "absl/strings/escaping.h"
 #include "http2/platform/api/http2_string_utils.h"
-
 #include "common/platform/api/quiche_test.h"
 
 namespace http2 {
@@ -105,7 +105,7 @@
   // a single ResumeEncoding() call.
   for (size_t i = 0; i < ABSL_ARRAYSIZE(kLongTestData); ++i) {
     std::string expected_encoding =
-        Http2HexDecode(kLongTestData[i].expected_encoding);
+        absl::HexStringToBytes(kLongTestData[i].expected_encoding);
 
     std::string output;
     HpackVarintEncoder::Encode(kLongTestData[i].high_bits,
@@ -145,16 +145,16 @@
 // Test that encoder appends correctly to non-empty string.
 TEST(HpackVarintEncoderTest, Append) {
   std::string output("foo");
-  EXPECT_EQ(Http2HexDecode("666f6f"), output);
+  EXPECT_EQ(absl::HexStringToBytes("666f6f"), output);
 
   HpackVarintEncoder::Encode(0b10011000, 3, 103, &output);
-  EXPECT_EQ(Http2HexDecode("666f6f9f60"), output);
+  EXPECT_EQ(absl::HexStringToBytes("666f6f9f60"), output);
 
   HpackVarintEncoder::Encode(0b10100000, 5, 8, &output);
-  EXPECT_EQ(Http2HexDecode("666f6f9f60a8"), output);
+  EXPECT_EQ(absl::HexStringToBytes("666f6f9f60a8"), output);
 
   HpackVarintEncoder::Encode(0b10011000, 3, 202147110, &output);
-  EXPECT_EQ(Http2HexDecode("666f6f9f60a89f9f8ab260"), output);
+  EXPECT_EQ(absl::HexStringToBytes("666f6f9f60a89f9f8ab260"), output);
 }
 
 }  // namespace
diff --git a/http2/http2_structures.cc b/http2/http2_structures.cc
index dda0dd8..a96edcc 100644
--- a/http2/http2_structures.cc
+++ b/http2/http2_structures.cc
@@ -7,6 +7,7 @@
 #include <cstring>  // For std::memcmp
 #include <sstream>
 
+#include "absl/strings/escaping.h"
 #include "absl/strings/str_cat.h"
 #include "http2/platform/api/http2_string_utils.h"
 
@@ -98,7 +99,9 @@
 
 std::ostream& operator<<(std::ostream& out, const Http2PingFields& v) {
   return out << "opaque_bytes=0x"
-             << Http2HexEncode(v.opaque_bytes, sizeof v.opaque_bytes);
+             << absl::BytesToHexString(absl::string_view(
+                    reinterpret_cast<const char*>(v.opaque_bytes),
+                    sizeof v.opaque_bytes));
 }
 
 // Http2GoAwayFields:
diff --git a/http2/platform/api/http2_string_utils.h b/http2/platform/api/http2_string_utils.h
index 087bd25..730b515 100644
--- a/http2/platform/api/http2_string_utils.h
+++ b/http2/platform/api/http2_string_utils.h
@@ -19,14 +19,6 @@
   return Http2StringPrintfImpl(std::forward<const Args&>(args)...);
 }
 
-inline std::string Http2HexEncode(const void* bytes, size_t size) {
-  return Http2HexEncodeImpl(bytes, size);
-}
-
-inline std::string Http2HexDecode(absl::string_view data) {
-  return Http2HexDecodeImpl(data);
-}
-
 inline std::string Http2HexDump(absl::string_view data) {
   return Http2HexDumpImpl(data);
 }
diff --git a/http2/test_tools/http2_random.cc b/http2/test_tools/http2_random.cc
index c9a071d..8f9014e 100644
--- a/http2/test_tools/http2_random.cc
+++ b/http2/test_tools/http2_random.cc
@@ -1,5 +1,6 @@
 #include "http2/test_tools/http2_random.h"
 
+#include "absl/strings/escaping.h"
 #include "http2/platform/api/http2_logging.h"
 #include "http2/platform/api/http2_string_utils.h"
 #include "third_party/boringssl/src/include/openssl/chacha.h"
@@ -17,13 +18,14 @@
 }
 
 Http2Random::Http2Random(absl::string_view key) {
-  std::string decoded_key = Http2HexDecode(key);
+  std::string decoded_key = absl::HexStringToBytes(key);
   QUICHE_CHECK_EQ(sizeof(key_), decoded_key.size());
   memcpy(key_, decoded_key.data(), sizeof(key_));
 }
 
 std::string Http2Random::Key() const {
-  return Http2HexEncode(key_, sizeof(key_));
+  return absl::BytesToHexString(
+      absl::string_view(reinterpret_cast<const char*>(key_), sizeof(key_)));
 }
 
 void Http2Random::FillRandom(void* buffer, size_t buffer_size) {