diff options
| author | Juan Linietsky | 2017-01-25 14:52:40 -0300 |
|---|---|---|
| committer | GitHub | 2017-01-25 14:52:40 -0300 |
| commit | 4c28f35b2c6dacd30a0e10453af1bcd977de9342 (patch) | |
| tree | 8d843a57b0a49a6bc09a799a5fc7bdb3540b944b /core | |
| parent | 7e1afeafd4a347c309562c6783119f64e99fc317 (diff) | |
| parent | 7dbb1c0571c0d1fb26c28552b09430807cc4d717 (diff) | |
| download | godot-4c28f35b2c6dacd30a0e10453af1bcd977de9342.tar.gz godot-4c28f35b2c6dacd30a0e10453af1bcd977de9342.tar.zst godot-4c28f35b2c6dacd30a0e10453af1bcd977de9342.zip | |
Diffstat (limited to 'core')
| -rw-r--r-- | core/ustring.cpp | 11 | ||||
| -rw-r--r-- | core/ustring.h | 1 | ||||
| -rw-r--r-- | core/variant_parser.cpp | 10 |
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; |
