diff --git a/Source/Engine/Core/Types/String.cpp b/Source/Engine/Core/Types/String.cpp
index 103dbaf00..1cd9fde88 100644
--- a/Source/Engine/Core/Types/String.cpp
+++ b/Source/Engine/Core/Types/String.cpp
@@ -21,6 +21,84 @@ String::String(const StringAnsiView& str)
Set(str.Get(), str.Length());
}
+void String::Set(const Char* chars, int32 length)
+{
+ if (length != _length)
+ {
+ ASSERT(length >= 0);
+ Platform::Free(_data);
+ if (length != 0)
+ {
+ _data = (Char*)Platform::Allocate((length + 1) * sizeof(Char), 16);
+ _data[length] = 0;
+ }
+ else
+ {
+ _data = nullptr;
+ }
+ _length = length;
+ }
+
+ Platform::MemoryCopy(_data, chars, length * sizeof(Char));
+}
+
+void String::Set(const char* chars, int32 length)
+{
+ if (length != _length)
+ {
+ Platform::Free(_data);
+ if (length != 0)
+ {
+ _data = (Char*)Platform::Allocate((length + 1) * sizeof(Char), 16);
+ _data[length] = 0;
+ }
+ else
+ {
+ _data = nullptr;
+ }
+ _length = length;
+ }
+
+ if (chars)
+ StringUtils::ConvertANSI2UTF16(chars, _data, length);
+}
+
+void String::Append(const Char* chars, int32 count)
+{
+ if (count == 0)
+ return;
+
+ const auto oldData = _data;
+ const auto oldLength = _length;
+
+ _length = oldLength + count;
+ _data = (Char*)Platform::Allocate((_length + 1) * sizeof(Char), 16);
+
+ Platform::MemoryCopy(_data, oldData, oldLength * sizeof(Char));
+ Platform::MemoryCopy(_data + oldLength, chars, count * sizeof(Char));
+ _data[_length] = 0;
+
+ Platform::Free(oldData);
+}
+
+void String::Append(const char* chars, int32 count)
+{
+ if (count == 0)
+ return;
+
+ const auto oldData = _data;
+ const auto oldLength = _length;
+
+ _length = oldLength + count;
+ _data = (Char*)Platform::Allocate((_length + 1) * sizeof(Char), 16);
+
+ Platform::MemoryCopy(_data, oldData, oldLength * sizeof(Char));
+ StringUtils::ConvertANSI2UTF16(chars, _data + oldLength, count * sizeof(Char));
+ _data[_length] = 0;
+
+ Platform::Free(oldData);
+}
+
String& String::operator+=(const StringView& str)
{
Append(str.Get(), str.Length());
@@ -149,6 +227,22 @@ bool String::EndsWith(const StringView& suffix, StringSearchCase searchCase) con
return !StringUtils::Compare(&(*this)[Length() - suffix.Length()], *suffix);
}
+String String::ToLower() const
+{
+ String result(*this);
+ for (int32 i = 0; i < result.Length(); i++)
+ result[i] = StringUtils::ToLower(result[i]);
+ return result;
+}
+
+String String::ToUpper() const
+{
+ String result(*this);
+ for (int32 i = 0; i < result.Length(); i++)
+ result[i] = StringUtils::ToUpper(result[i]);
+ return result;
+}
+
void String::TrimToNullTerminator()
{
const int32 length = _length;
diff --git a/Source/Engine/Core/Types/String.h b/Source/Engine/Core/Types/String.h
index cf21a1236..c42d82dde 100644
--- a/Source/Engine/Core/Types/String.h
+++ b/Source/Engine/Core/Types/String.h
@@ -617,100 +617,30 @@ public:
///
/// Sets an array of characters to the string.
///
- /// The pointer to the start of an array of characters to set. This array need not be null-terminated, and null characters are not treated specially.
+ /// The pointer to the start of an array of characters to set (UTF-16). This array need not be null-terminated, and null characters are not treated specially.
/// The number of characters to assign.
- void Set(const Char* chars, int32 length)
- {
- if (length != _length)
- {
- ASSERT(length >= 0);
- Platform::Free(_data);
- if (length != 0)
- {
- _data = (Char*)Platform::Allocate((length + 1) * sizeof(Char), 16);
- _data[length] = 0;
- }
- else
- {
- _data = nullptr;
- }
- _length = length;
- }
-
- Platform::MemoryCopy(_data, chars, length * sizeof(Char));
- }
+ void Set(const Char* chars, int32 length);
///
/// Sets an array of characters to the string.
///
- /// The pointer to the start of an array of characters to set. This array need not be null-terminated, and null characters are not treated specially.
+ /// The pointer to the start of an array of characters to set (ANSI). This array need not be null-terminated, and null characters are not treated specially.
/// The number of characters to assign.
- void Set(const char* chars, int32 length)
- {
- if (length != _length)
- {
- Platform::Free(_data);
- if (length != 0)
- {
- _data = (Char*)Platform::Allocate((length + 1) * sizeof(Char), 16);
- _data[length] = 0;
- }
- else
- {
- _data = nullptr;
- }
- _length = length;
- }
-
- if (chars)
- StringUtils::ConvertANSI2UTF16(chars, _data, length);
- }
+ void Set(const char* chars, int32 length);
///
/// Appends an array of characters to the string.
///
/// The array of characters to append. It does not need be null-terminated, and null characters are not treated specially.
/// The number of characters to append.
- void Append(const Char* chars, int32 count)
- {
- if (count == 0)
- return;
-
- const auto oldData = _data;
- const auto oldLength = _length;
-
- _length = oldLength + count;
- _data = (Char*)Platform::Allocate((_length + 1) * sizeof(Char), 16);
-
- Platform::MemoryCopy(_data, oldData, oldLength * sizeof(Char));
- Platform::MemoryCopy(_data + oldLength, chars, count * sizeof(Char));
- _data[_length] = 0;
-
- Platform::Free(oldData);
- }
+ void Append(const Char* chars, int32 count);
///
/// Appends an array of characters to the string.
///
/// The array of characters to append. It does not need be null-terminated, and null characters are not treated specially.
/// The number of characters to append.
- void Append(const char* chars, int32 count)
- {
- if (count == 0)
- return;
-
- const auto oldData = _data;
- const auto oldLength = _length;
-
- _length = oldLength + count;
- _data = (Char*)Platform::Allocate((_length + 1) * sizeof(Char), 16);
-
- Platform::MemoryCopy(_data, oldData, oldLength * sizeof(Char));
- StringUtils::ConvertANSI2UTF16(chars, _data + oldLength, count * sizeof(Char));
- _data[_length] = 0;
-
- Platform::Free(oldData);
- }
+ void Append(const char* chars, int32 count);
///
/// Appends the specified text to this string.
@@ -990,25 +920,13 @@ public:
/// Converts all uppercase characters to lowercase.
///
/// The lowercase string.
- String ToLower() const
- {
- String result(*this);
- for (int32 i = 0; i < result.Length(); i++)
- result[i] = StringUtils::ToLower(result[i]);
- return result;
- }
+ String ToLower() const;
///
/// Converts all lowercase characters to uppercase.
///
/// The uppercase string.
- String ToUpper() const
- {
- String result(*this);
- for (int32 i = 0; i < result.Length(); i++)
- result[i] = StringUtils::ToUpper(result[i]);
- return result;
- }
+ String ToUpper() const;
///
/// Gets the left most given number of characters.