diff --git a/common/fuzzing/proto_to_carbon.cpp b/common/fuzzing/proto_to_carbon.cpp index 60878aad9633..d53c6cd29045 100644 --- a/common/fuzzing/proto_to_carbon.cpp +++ b/common/fuzzing/proto_to_carbon.cpp @@ -45,7 +45,7 @@ static auto IdentifierToCarbon(std::string_view s, llvm::raw_ostream& out) static auto StringLiteralToCarbon(std::string_view s, llvm::raw_ostream& out) { out << '"'; - out.write_escaped(s); + out.write_escaped(s, /*UseHexEscapes=*/true); out << '"'; } diff --git a/explorer/testdata/string/hex.carbon b/explorer/testdata/string/hex.carbon index 3fd0cc18acea..173edd6a8619 100644 --- a/explorer/testdata/string/hex.carbon +++ b/explorer/testdata/string/hex.carbon @@ -12,12 +12,12 @@ package ExplorerTest api; fn CompareStr(s: String) -> i32 { - if (s == "str;") { + if (s == "str;\x07") { return 0; } return 1; } fn Main() -> i32 { - return CompareStr("\x73\x74\x72\x3B"); + return CompareStr("\x73\x74\x72\x3B\x07"); }