diff options
author | Haoyu Qiu <timothyqiu32@gmail.com> | 2019-12-20 10:03:15 +0800 |
---|---|---|
committer | Haoyu Qiu <timothyqiu32@gmail.com> | 2019-12-20 10:42:08 +0800 |
commit | e7e095da3fd9140cfbbe11dd178981633819d642 (patch) | |
tree | 02dcd052616cfc5c7581581dda2843365b275480 /core/ustring.cpp | |
parent | 2a4c528d067826dd1af865c93c3dc945c9a0e196 (diff) | |
download | redot-engine-e7e095da3fd9140cfbbe11dd178981633819d642.tar.gz |
Encodes property names properly in project.godot
Diffstat (limited to 'core/ustring.cpp')
-rw-r--r-- | core/ustring.cpp | 13 |
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("."); |