From fcc6bbe79742fd6ccdda6c38063af4324a4e5b5b Mon Sep 17 00:00:00 2001 From: wraitii Date: Fri, 9 Apr 2021 18:08:37 +0000 Subject: [PATCH] Fix d73a3f59ad - wstring_view on a temporary & wrong utf16->8 conversion. Two issues: - The wstring_view was created on a temporary string - the data got overwritten sometimes. - there was some weird UTF16->UTF8 conversion going on. Reported by: langbart Differential Revision: https://code.wildfiregames.com/D3828 This was SVN commit r25226. --- source/ps/TemplateLoader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/ps/TemplateLoader.cpp b/source/ps/TemplateLoader.cpp index 2add151b6e..3789d02889 100644 --- a/source/ps/TemplateLoader.cpp +++ b/source/ps/TemplateLoader.cpp @@ -91,17 +91,17 @@ static Status AddToTemplates(const VfsPath& pathname, const CFileInfo& UNUSED(fi // Strip the .xml extension VfsPath pathstem = pathname.ChangeExtension(L""); // Strip the root from the path - std::wstring_view name = pathstem.string().substr(ARRAY_SIZE(TEMPLATE_ROOT)-1); + std::string name = pathstem.string8().substr(ARRAY_SIZE(TEMPLATE_ROOT)-1); // We want to ignore template_*.xml templates, since they should never be built in the editor - if (name.substr(0, 9) == L"template_") + if (name.substr(0, 9) == "template_") return INFO::OK; // Also ignore some subfolders. - if (name.substr(0, 8) == L"special/" || name.substr(0, 7) == L"mixins/") + if (name.substr(0, 8) == "special/" || name.substr(0, 7) == "mixins/") return INFO::OK; - templates.push_back(std::string(name.begin(), name.end())); + templates.push_back(name); return INFO::OK; }