mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-26 00:45:35 +00:00
Codechange: Replace remaining Utf8Encode usages with StringBuilder.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "../stdafx.h"
|
||||
#include "../string_func.h"
|
||||
#include "../strings_func.h"
|
||||
#include "../core/string_builder.hpp"
|
||||
#include "saveload_internal.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
@@ -63,8 +64,8 @@ std::string CopyFromOldName(StringID id)
|
||||
if (IsSavegameVersionBefore(SLV_37)) {
|
||||
const std::string &strfrom = _old_name_array[GB(id, 0, 9)];
|
||||
|
||||
std::ostringstream tmp;
|
||||
std::ostreambuf_iterator<char> strto(tmp);
|
||||
std::string result;
|
||||
StringBuilder builder(result);
|
||||
for (char s : strfrom) {
|
||||
if (s == '\0') break;
|
||||
char32_t c = static_cast<uint8_t>(s); // cast to unsigned before integer promotion
|
||||
@@ -82,10 +83,10 @@ std::string CopyFromOldName(StringID id)
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (IsPrintable(c)) Utf8Encode(strto, c);
|
||||
if (IsPrintable(c)) builder.PutUtf8(c);
|
||||
}
|
||||
|
||||
return tmp.str();
|
||||
return result;
|
||||
} else {
|
||||
/* Name will already be in UTF-8. */
|
||||
return StrMakeValid(_old_name_array[GB(id, 0, 9)]);
|
||||
|
||||
Reference in New Issue
Block a user