aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky2017-01-25 14:52:40 -0300
committerGitHub2017-01-25 14:52:40 -0300
commit4c28f35b2c6dacd30a0e10453af1bcd977de9342 (patch)
tree8d843a57b0a49a6bc09a799a5fc7bdb3540b944b /core
parent7e1afeafd4a347c309562c6783119f64e99fc317 (diff)
parent7dbb1c0571c0d1fb26c28552b09430807cc4d717 (diff)
downloadgodot-4c28f35b2c6dacd30a0e10453af1bcd977de9342.tar.gz
godot-4c28f35b2c6dacd30a0e10453af1bcd977de9342.tar.zst
godot-4c28f35b2c6dacd30a0e10453af1bcd977de9342.zip
Diffstat (limited to 'core')
-rw-r--r--core/ustring.cpp11
-rw-r--r--core/ustring.h1
-rw-r--r--core/variant_parser.cpp10
3 files changed, 16 insertions, 6 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 478c427fb..a0d26ea0a 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -3410,8 +3410,17 @@ String String::c_escape() const {
escaped=escaped.replace("\t","\\t");
escaped=escaped.replace("\v","\\v");
escaped=escaped.replace("\'","\\'");
- escaped=escaped.replace("\"","\\\"");
escaped=escaped.replace("\?","\\?");
+ escaped=escaped.replace("\"","\\\"");
+
+ return escaped;
+}
+
+String String::c_escape_multiline() const {
+
+ String escaped=*this;
+ escaped=escaped.replace("\\","\\\\");
+ escaped=escaped.replace("\"","\\\"");
return escaped;
}
diff --git a/core/ustring.h b/core/ustring.h
index 426762a9e..5665a2311 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -218,6 +218,7 @@ public:
String http_escape() const;
String http_unescape() const;
String c_escape() const;
+ String c_escape_multiline() const;
String c_unescape() const;
String json_escape() const;
String word_wrap(int p_chars_per_line) const;
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index a833a275d..1e938b489 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -1873,7 +1873,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
String str=p_variant;
- str="\""+str.c_escape()+"\"";
+ str="\""+str.c_escape_multiline()+"\"";
p_store_string_func(p_store_string_ud, str );
} break;
case Variant::VECTOR2: {
@@ -2091,7 +2091,7 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
dict.get_key_list(&keys);
keys.sort();
- p_store_string_func(p_store_string_ud,"{ ");
+ p_store_string_func(p_store_string_ud,"{\n");
for(List<Variant>::Element *E=keys.front();E;E=E->next()) {
/*
@@ -2099,14 +2099,14 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str
continue;
*/
write(E->get(),p_store_string_func,p_store_string_ud,p_encode_res_func,p_encode_res_ud);
- p_store_string_func(p_store_string_ud,":");
+ p_store_string_func(p_store_string_ud,": ");
write(dict[E->get()],p_store_string_func,p_store_string_ud,p_encode_res_func,p_encode_res_ud);
if (E->next())
- p_store_string_func(p_store_string_ud,", ");
+ p_store_string_func(p_store_string_ud,",\n");
}
- p_store_string_func(p_store_string_ud," }");
+ p_store_string_func(p_store_string_ud,"\n}");
} break;