mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-24 01:25:33 +00:00
fix handling of escaped chars in json backend and frontend
This commit is contained in:
parent
1586000048
commit
8fd1b06249
5 changed files with 63 additions and 5 deletions
|
@ -52,8 +52,23 @@ struct JsonWriter
|
|||
string newstr = "\"";
|
||||
for (char c : str) {
|
||||
if (c == '\\')
|
||||
newstr += "\\\\";
|
||||
else if (c == '"')
|
||||
newstr += "\\\"";
|
||||
else if (c == '\b')
|
||||
newstr += "\\b";
|
||||
else if (c == '\f')
|
||||
newstr += "\\f";
|
||||
else if (c == '\n')
|
||||
newstr += "\\n";
|
||||
else if (c == '\r')
|
||||
newstr += "\\r";
|
||||
else if (c == '\t')
|
||||
newstr += "\\t";
|
||||
else if (c < 0x20)
|
||||
newstr += stringf("\\u%04X", c);
|
||||
else
|
||||
newstr += c;
|
||||
newstr += c;
|
||||
}
|
||||
return newstr + "\"";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue