Remove old C string handling from OrderedJson

This commit is contained in:
GriffinR
2025-06-08 17:22:22 -04:00
parent 591b7c2055
commit 5474152c7e
2 changed files with 2 additions and 34 deletions

View File

@@ -12,6 +12,7 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp
- Fix duplicated maps writing the wrong name.
- Fix small maps being difficult to see while resizing.
- Fix expressions using the prefix '0X' as opposed to '0x' not being recognized has hex numbers.
- Fix certain characters not writing correctly to JSON files.
## [6.0.0] - 2025-05-26
### Breaking Changes

View File

@@ -77,40 +77,7 @@ static void dump(bool value, QString &out, int *indent) {
static void dump(const QString &value, QString &out, int *indent, bool isKey = false) {
if (!isKey && !out.endsWith(": ")) out += QString(*indent * 2, ' ');
out += '"';
for (int i = 0; i < value.length(); i++) {
const char ch = value[i].unicode();
if (ch == '\\') {
out += "\\\\";
} else if (ch == '"') {
out += "\\\"";
} else if (ch == '\b') {
out += "\\b";
} else if (ch == '\f') {
out += "\\f";
} else if (ch == '\n') {
out += "\\n";
} else if (ch == '\r') {
out += "\\r";
} else if (ch == '\t') {
out += "\\t";
} else if (static_cast<uint8_t>(ch) <= 0x1f) {
char buf[8];
snprintf(buf, sizeof buf, "\\u%04x", ch);
out += buf;
} else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1].unicode()) == 0x80
&& static_cast<uint8_t>(value[i+2].unicode()) == 0xa8) {
out += "\\u2028";
i += 2;
} else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1].unicode()) == 0x80
&& static_cast<uint8_t>(value[i+2].unicode()) == 0xa9) {
out += "\\u2029";
i += 2;
} else {
out += ch;
}
}
out += '"';
out += QString("\"%1\"").arg(value.toUtf8());
}
static void dump(const Json::array &values, QString &out, int *indent) {