mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Do not escape UNICODE when writing out target info.
Escaping unicode characters results in invalid JSON. - Refactor writeEscaped routine into StringExtras Resolves rdar://90108531
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace swift;
|
||||
@@ -1392,3 +1393,27 @@ Optional<StringRef> swift::stripWithCompletionHandlerSuffix(StringRef name) {
|
||||
|
||||
return None;
|
||||
}
|
||||
|
||||
void swift::writeEscaped(llvm::StringRef Str, llvm::raw_ostream &OS) {
|
||||
for (unsigned i = 0, e = Str.size(); i != e; ++i) {
|
||||
unsigned char c = Str[i];
|
||||
|
||||
switch (c) {
|
||||
case '\\':
|
||||
OS << '\\' << '\\';
|
||||
break;
|
||||
case '\t':
|
||||
OS << '\\' << 't';
|
||||
break;
|
||||
case '\n':
|
||||
OS << '\\' << 'n';
|
||||
break;
|
||||
case '"':
|
||||
OS << '\\' << '"';
|
||||
break;
|
||||
default:
|
||||
OS << c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user