From e7e095da3fd9140cfbbe11dd178981633819d642 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Fri, 20 Dec 2019 10:03:15 +0800 Subject: Encodes property names properly in project.godot --- core/ustring.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'core/ustring.cpp') 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("."); -- cgit v1.2.3