diff options
Diffstat (limited to 'src/passes')
-rw-r--r-- | src/passes/Print.cpp | 8 | ||||
-rw-r--r-- | src/passes/StringLowering.cpp | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 643f1cc3f..80047a281 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2232,7 +2232,13 @@ struct PrintExpressionContents } void visitStringConst(StringConst* curr) { printMedium(o, "string.const "); - String::printEscaped(o, curr->string.str); + // Re-encode from WTF-16 to WTF-8. + std::stringstream wtf8; + [[maybe_unused]] bool valid = + String::convertWTF16ToWTF8(wtf8, curr->string.str); + assert(valid); + // TODO: Use wtf8.view() once we have C++20. + String::printEscaped(o, wtf8.str()); } void visitStringMeasure(StringMeasure* curr) { switch (curr->op) { diff --git a/src/passes/StringLowering.cpp b/src/passes/StringLowering.cpp index e0d3fbad0..322f0deb2 100644 --- a/src/passes/StringLowering.cpp +++ b/src/passes/StringLowering.cpp @@ -147,8 +147,14 @@ struct StringGathering : public Pass { } auto& string = strings[i]; + // Re-encode from WTF-16 to WTF-8 to make the name easier to read. + std::stringstream wtf8; + [[maybe_unused]] bool valid = + String::convertWTF16ToWTF8(wtf8, string.str); + assert(valid); + // TODO: Use wtf8.view() once we have C++20. auto name = Names::getValidGlobalName( - *module, std::string("string.const_") + std::string(string.str)); + *module, std::string("string.const_") + std::string(wtf8.str())); globalName = name; newNames.insert(name); auto* stringConst = builder.makeStringConst(string); |