summaryrefslogtreecommitdiffstats
path: root/core/ustring.cpp
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2019-12-20 10:03:15 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2019-12-20 10:42:08 +0800
commite7e095da3fd9140cfbbe11dd178981633819d642 (patch)
tree02dcd052616cfc5c7581581dda2843365b275480 /core/ustring.cpp
parent2a4c528d067826dd1af865c93c3dc945c9a0e196 (diff)
downloadredot-engine-e7e095da3fd9140cfbbe11dd178981633819d642.tar.gz
Encodes property names properly in project.godot
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r--core/ustring.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 502e6a5a88..09a02a09be 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -4059,6 +4059,19 @@ String String::percent_decode() const {
return String::utf8(pe.ptr());
}
+String String::property_name_encode() const {
+ // Escape and quote strings with extended ASCII or further Unicode characters
+ // as well as '"', '=' or ' ' (32)
+ const CharType *cstr = c_str();
+ for (int i = 0; cstr[i]; i++) {
+ if (cstr[i] == '=' || cstr[i] == '"' || cstr[i] < 33 || cstr[i] > 126) {
+ return "\"" + c_escape_multiline() + "\"";
+ }
+ }
+ // Keep as is
+ return *this;
+}
+
String String::get_basename() const {
int pos = find_last(".");