Navigation
API > API/Runtime > API/Runtime/Core
A dynamically sizeable string. When dealing with UTF-8 literals, the following advice is recommended:
- Do not use the u8"..." prefix (gives the wrong array type until C++20).
- Use UTF8TEXT("...") for array literals (type is const UTF8CHAR[n]).
- Use UTF8TEXTVIEW("...") for string view literals (type is FUtf8StringView).
- Use \uxxxx or \Uxxxxxxxx escape sequences rather than \x to specify Unicode code points.
| Name | FString |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Containers/UnrealString.h.inl |
| Include Path | #include "Containers/UnrealString.h.inl" |
Syntax
class FString
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FString
(
FIntrusiveUnsetOptionalState Tag |
|||
| Create a copy of the Other string with extra space for characters at the end of the string | |||
FString
(
CharRangeType&& Str, |
Construct from contiguous range of characters with extra slack on top of original string length | ||
FString () |
|||
consteval FString
(
EConstEval |
|||
| Create a copy of the Other string with extra space for characters at the end of the string | |||
FString
(
const UCS2CHAR* Str |
|||
FString
(
const UTF32CHAR* Str |
|||
UE_FORCEINLINE_HINT FString
(
CharRangeType&& Str |
Construct from contiguous range of characters such as a string view or string builder | ||
FString
(
const UTF8CHAR* Str |
|||
FString
(
const WIDECHAR* Str |
|||
FString
(
const ANSICHAR* Str |
Construct from null-terminated C string or nullptr |
Typedefs
| Name | Type | Remarks | Include Path | | --- | --- | --- | --- |Constants
| Name | Type | Remarks | Include Path | | --- | --- | --- | --- |Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers | | --- | --- | --- | --- | --- |Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers | | --- | --- | --- | --- | --- |Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Append a valid null-terminated string and return a reference to this | |||
| Append a string and return a reference to this | |||
| Append a string and return a reference to this | |||
FString & AppendChar
(
ElementType InChar |
Append a single character and return a reference to this | ||
void AppendChars
(
const WIDECHAR* Str, |
|||
void AppendChars
(
const UTF32CHAR* Str, |
|||
void AppendChars
(
const UTF8CHAR* Str, |
|||
void AppendChars
(
const UCS2CHAR* Str, |
|||
void AppendChars
(
const ANSICHAR* Str, |
Appends a character range without null-terminators in it | ||
FString & Appendf
(
UE::Core::TCheckedFormatString< FmtCharType, Types... > Fmt, |
Just like Printf, but appends the formatted text to the existing string instead. | ||
void AppendInt
(
int32 InNum |
Appends the integer InNum to this string | ||
UE_FORCEINLINE_HINTDataType::RangedForIteratorType begin () |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. | ||
UE_FORCEINLINE_HINTDataType::RangedForConstIteratorType begin () |
|||
void CheckInvariants() |
Run slow checks on this string | ||
int32 Compare
(
const FString& Other, |
Lexicographically tests how this string compares to the Other given string | ||
bool Contains
(
CharRangeType&& SubStr, |
Returns whether this string contains the specified substring. | ||
UE_FORCEINLINE_HINT bool Contains
(
const ElementType* SubStr, |
Returns whether this string contains the specified substring. | ||
UE_FORCEINLINE_HINT bool Contains
(
const FString& SubStr, |
Returns whether this string contains the specified substring. | ||
UE_FORCEINLINE_HINT bool Contains
(
const ElementType* SubStr, |
Returns whether this string contains the specified substring. | ||
FString ConvertTabsToSpaces
(
const int32 InSpacesPerTab |
Replaces all instances of '\t' with TabWidth number of spaces | ||
FString ConvertTabsToSpaces
(
const int32 InSpacesPerTab |
Replaces all instances of '\t' with TabWidth number of spaces | ||
void ConvertTabsToSpacesInline
(
const int32 InSpacesPerTab |
Replaces all instances of '\t' with TabWidth number of spaces | ||
UE_FORCEINLINE_HINT void CountBytes
(
FArchive& Ar |
|||
UE_FORCEINLINE_HINTTConstIterator CreateConstIterator() |
Creates a const iterator for the characters in this string | ||
UE_FORCEINLINE_HINTTIterator CreateIterator() |
Creates an iterator for the characters in this string | ||
void Empty () |
Create empty string of given size with zero terminating character | ||
void Empty
(
int32 Slack |
|||
UE_FORCEINLINE_HINTDataType::RangedForIteratorType end () |
|||
UE_FORCEINLINE_HINTDataType::RangedForConstIteratorType end () |
|||
bool EndsWith
(
const ElementType* InSuffix, |
Test whether this string ends with given suffix. | ||
bool EndsWith
(
CharRangeType&& InSuffix, |
Test whether this string ends with given suffix. | ||
bool EndsWith
(
const FString& InSuffix, |
Test whether this string ends with given suffix. | ||
bool EndsWith
(
const ElementType* InSuffix, |
Test whether this string ends with given suffix. | ||
bool Equals
(
const FString& Other, |
Lexicographically tests whether this string is equivalent to the Other given string | ||
int32 Find
(
CharRangeType&& SubStr, |
Searches the string for a substring. | ||
int32 Find
(
const ElementType* SubStr, |
Searches the string for a substring. | ||
int32 Find
(
const FString& SubStr, |
Searches the string for a substring. | ||
int32 Find
(
const ElementType* SubStr, |
Searches the string for a substring. | ||
UE_FORCEINLINE_HINT bool FindChar
(
ElementType InChar, |
Searches the string for a character | ||
UE_FORCEINLINE_HINT bool FindLastChar
(
ElementType InChar, |
Searches the string for the last occurrence of a character | ||
UE_FORCEINLINE_HINTint32 FindLastCharByPredicate
(
Predicate Pred |
Searches the string for the last occurrence of a character which matches the specified predicate. | ||
int32 FindLastCharByPredicate
(
Predicate Pred, |
Searches an initial substring for the last occurrence of a character which matches the specified predicate. | ||
UE_FORCEINLINE_HINTSIZE_T GetAllocatedSize() |
|||
UE_FORCEINLINE_HINT const DataType & GetCharArray () |
Get string as const array of TCHARS | ||
UE_FORCEINLINE_HINTDataType & GetCharArray () |
Get string as array of TCHARS | ||
void InsertAt
(
int32 Index, |
|||
UE_FORCEINLINE_HINT bool IsEmpty() |
Test whether this string is empty | ||
bool IsNumeric() |
Returns true if the string only contains numeric characters | ||
UE_FORCEINLINE_HINT bool IsValidIndex
(
int32 Index |
Tests if index is valid, i.e. greater than or equal to zero, and less than the number of characters in this string (excluding the null terminator). | ||
| Returns the left most given number of characters | |||
| Returns the left most characters from the string chopping the given number of characters from the end | |||
void LeftChopInline
(
int32 Count, |
Modifies the string such that it is now the left most characters chopping the given number of characters from the end | ||
void LeftInline
(
int32 Count, |
Modifies the string such that it is now the left most given number of characters | ||
FString LeftPad
(
int32 ChCount |
Pad the left of this string for ChCount characters | ||
UE_FORCEINLINE_HINTint32 Len() |
Get the length of the string, excluding terminating character | ||
bool MatchesWildcard
(
const FString& Wildcard, |
Searches this string for a given wild cardThis is a simple, SLOW routine. Use with caution | ||
bool MatchesWildcard
(
const ElementType* Wildcard, |
Searches this string for a given wild cardThis is a simple, SLOW routine. Use with caution | ||
bool MatchesWildcard
(
const ElementType* Wildcard, |
Searches this string for a given wild cardThis is a simple, SLOW routine. Use with caution | ||
bool MatchesWildcard
(
CharRangeType&& Wildcard, |
Searches this string for a given wild cardThis is a simple, SLOW routine. Use with caution | ||
| Returns the substring from Start position to the end | |||
| Returns the substring from Start position for Count characters. | |||
void MidInline
(
int32 Start, |
Modifies the string such that it is now the substring from Start position for Count characters. | ||
UE_FORCEINLINE_HINTSIZE_T NumBytesWithNull() |
|||
UE_FORCEINLINE_HINTSIZE_T NumBytesWithoutNull() |
|||
int32 ParseIntoArray
(
TArray< FString >& OutArray, |
Breaks up a delimited string into elements of a string array, using the given delimiters | ||
int32 ParseIntoArray
(
TArray< FString >& OutArray, |
Breaks up a delimited string into elements of a string array. | ||
int32 ParseIntoArrayLines
(
TArray< FString >& OutArray, |
Breaks up a delimited string into elements of a string array, using line ending characters | ||
int32 ParseIntoArrayWS
(
TArray< FString >& OutArray, |
Breaks up a delimited string into elements of a string array, using any whitespace and an optional extra delimter, like a "," | ||
void PathAppend
(
const ElementType* Str, |
Concatenate this path with given path ensuring the / character is used between them | ||
UE_FORCEINLINE_HINTDataType::RangedForConstReverseIteratorType rbegin () |
|||
UE_FORCEINLINE_HINTDataType::RangedForReverseIteratorType rbegin () |
|||
void RemoveAt
(
int32 Index, |
Removes a character from the string. | ||
void RemoveAt
(
int32 Index, |
Removes characters within the string. | ||
bool RemoveFromEnd
(
CharRangeType&& InSuffix, |
Removes the text from the end of the string if it exists. | ||
bool RemoveFromEnd
(
const ElementType* InSuffix, |
Removes the text from the end of the string if it exists. | ||
bool RemoveFromEnd
(
const FString& InSuffix, |
Removes the text from the end of the string if it exists. | ||
bool RemoveFromEnd
(
const ElementType* InSuffix, |
Removes the text from the end of the string if it exists. | ||
bool RemoveFromStart
(
const FString& InPrefix, |
Removes the text from the start of the string if it exists. | ||
bool RemoveFromStart
(
CharRangeType&& InPrefix, |
Removes the text from the start of the string if it exists. | ||
bool RemoveFromStart
(
const ElementType* InPrefix, |
Removes the text from the start of the string if it exists. | ||
bool RemoveFromStart
(
const ElementType* InPrefix, |
Removes the text from the start of the string if it exists. | ||
void RemoveSpacesInline() |
Removes spaces from the string. I.E. "Spaces Are Cool" --> "SpacesAreCool". | ||
UE_FORCEINLINE_HINTDataType::RangedForReverseIteratorType rend () |
|||
UE_FORCEINLINE_HINTDataType::RangedForConstReverseIteratorType rend () |
|||
FString Replace
(
const ElementType* From, |
Returns a copy of the string with all occurrences of a substring replaced. | ||
FString Replace
(
const ElementType* From, |
Returns a copy of the string with all occurrences of a substring replaced. | ||
void ReplaceCharInline
(
ElementType From, |
Replaces all occurrences of a character in this string.no dynamic allocation | ||
FString ReplaceCharWithEscapedChar
(
const TArray< ElementType >* Chars |
Replaces certain characters with the "escaped" version of that character (i.e. replaces "\n" with "\n"). | ||
FString ReplaceCharWithEscapedChar
(
const TArray< ElementType >* Chars |
Replaces certain characters with the "escaped" version of that character (i.e. replaces "\n" with "\n"). | ||
void ReplaceCharWithEscapedCharInline
(
const TArray< ElementType >* Chars |
Replaces certain characters with the "escaped" version of that character (i.e. replaces "\n" with "\n"). | ||
FString ReplaceEscapedCharWithChar
(
const TArray< ElementType >* Chars |
Removes the escape backslash for all supported characters, replacing the escape and character with the non-escaped version. | ||
FString ReplaceEscapedCharWithChar
(
const TArray< ElementType >* Chars |
Removes the escape backslash for all supported characters, replacing the escape and character with the non-escaped version. | ||
void ReplaceEscapedCharWithCharInline
(
const TArray< ElementType >* Chars |
Removes the escape backslash for all supported characters, replacing the escape and character with the non-escaped version. | ||
int32 ReplaceInline
(
const ElementType* SearchText, |
Replaces all occurrences of a substring in this string. | ||
| Returns a copy of this string with all quote marks escaped (unless the quote is already escaped) | |||
| Returns a copy of this string with all quote marks escaped (unless the quote is already escaped) | |||
void Reserve
(
int32 CharacterCount |
To allow more efficient memory handling, automatically adds one for the string termination. | ||
void Reset
(
int32 NewReservedSize |
Empties the string, but doesn't change memory allocation, unless the new size is larger than the current string. | ||
| Returns a copy of this string, with the characters in reverse order | |||
| Returns this string, with the characters in reverse order | |||
void ReverseString() |
Reverses the order of characters in this string | ||
| Returns the string to the right of the specified location, counting back from the right (end of the word). | |||
| Returns the string to the right of the specified location, counting forward from the left (from the beginning of the word). | |||
UE_FORCEINLINE_HINT void RightChopInline
(
int32 Count, |
Modifies the string such that it is now the string to the right of the specified location, counting forward from the left (from the beginning of the word). | ||
void RightInline
(
int32 Count, |
Modifies the string such that it is now the right most given number of characters | ||
FString RightPad
(
int32 ChCount |
Pad the right of this string for ChCount characters | ||
void SerializeAsANSICharArray
(
FArchive& Ar, |
Serializes a string as ANSI char array. | ||
void Shrink() |
Remove unallocated empty character space from the end of this string | ||
bool Split
(
const FString& InStr, |
Splits this string at given string position case sensitive. | ||
| Split with ESearchCase::IgnoreCase and ESearchDir::FromStart. | |||
bool StartsWith
(
const ElementType* InPrefix, |
Test whether this string starts with given prefix. | ||
bool StartsWith
(
CharRangeType&& InPrefix, |
Test whether this string starts with given prefix. | ||
bool StartsWith
(
const FString& InPrefix, |
Test whether this string starts with given prefix. | ||
bool StartsWith
(
const ElementType* InPrefix, |
Test whether this string starts with given prefix. | ||
bool ToBool() |
Converts a string into a boolean value 1, "True", "Yes", FCoreTexts::True, FCoreTexts::Yes, and non-zero integers become true 0, "False", "No", FCoreTexts::False, FCoreTexts::No, and unparsable values become false | ||
| Returns a new string with the characters of this converted to lowercase | |||
| Converts all characters in this rvalue string to lowercase and moves it into the returned string. | |||
void ToLowerInline() |
Converts all characters in this string to lowercase | ||
| Returns a new string with the characters of this converted to uppercase | |||
| Converts all characters in this rvalue string to uppercase and moves it into the returned string. | |||
void ToUpperInline() |
Converts all characters in this string to uppercase | ||
| Returns a copy of this string with wrapping CharacterToTrim removed (removes at max one instance in the beginning and end of the string). | |||
| Returns a copy of this string with wrapping CharacterToTrim removed (removes at max one instance in the beginning and end of the string). | |||
void TrimCharInline
(
ElementType CharacterToTrim, |
Trims a single character from the start and end of the string (removes at max one instance in the beginning and end of the string). | ||
| Removes whitespace characters from the end of this string. | |||
| Removes whitespace characters from the end of this string. | |||
void TrimEndInline() |
Removes whitespace characters from the end of this string. Modifies the string in-place. | ||
FString TrimQuotes
(
bool* bQuotesRemoved |
Returns a copy of this string with wrapping quotation marks removed. | ||
FString TrimQuotes
(
bool* bQuotesRemoved |
Returns this string with wrapping quotation marks removed. | ||
void TrimQuotesInline
(
bool* bQuotesRemoved |
Trims wrapping quotation marks from this string. | ||
| Removes whitespace characters from the start of this string. | |||
| Removes whitespace characters from the start of this string. | |||
| Removes whitespace characters from the start and end of this string. | |||
| Removes whitespace characters from the start and end of this string. | |||
void TrimStartAndEndInline() |
Removes whitespace characters from the start and end of this string. Modifies the string in-place. | ||
void TrimStartInline() |
Removes whitespace characters from the start of this string. Modifies the string in-place. | ||
void TrimToNullTerminator() |
Trims the inner array after the null terminator. | ||
UE_FORCEINLINE_HINT bool UEOpEquals
(
const CharType* Rhs |
Lexicographically test whether the left string is == the right stringcase insensitive | ||
bool UEOpEquals
(
FIntrusiveUnsetOptionalState Tag |
|||
UE_FORCEINLINE_HINT bool UEOpEquals
(
const FString& Rhs |
Lexicographically test whether the left string is == the right stringcase insensitive | ||
UE_FORCEINLINE_HINT bool UEOpGreaterThan
(
const CharType* Rhs |
Lexicographically test whether the left string is > the right stringcase insensitive | ||
UE_FORCEINLINE_HINT bool UEOpLessThan
(
const FString& Rhs |
Lexicographically test whether the left string is < the right stringcase insensitive | ||
UE_FORCEINLINE_HINT bool UEOpLessThan
(
const CharType* Rhs |
Lexicographically test whether the left string is < the right stringcase insensitive |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static void AppendfImpl
(
FString& AppendToMe, |
|||
static FString Chr
(
ElementType Ch |
Returns a string containing only the Ch character | ||
static FString ChrN
(
int32 NumCharacters, |
Returns a string that is full of a variable number of characters | ||
static FString ConstructFromPtrSize
(
const ANSICHAR* Str, |
Construct from a buffer. | ||
static FString ConstructFromPtrSize
(
const WIDECHAR* Str, |
|||
static FString ConstructFromPtrSize
(
const UTF8CHAR* Str, |
|||
static FString ConstructFromPtrSize
(
const UCS2CHAR* Str, |
|||
static FString ConstructFromPtrSize
(
const UTF32CHAR* Str, |
|||
static FString ConstructFromPtrSizeWithSlack
(
const UCS2CHAR* Str, |
|||
static FString ConstructFromPtrSizeWithSlack
(
const WIDECHAR* Str, |
|||
static FString ConstructFromPtrSizeWithSlack
(
const UTF8CHAR* Str, |
|||
static FString ConstructFromPtrSizeWithSlack
(
const UTF32CHAR* Str, |
|||
static FString ConstructFromPtrSizeWithSlack
(
const ANSICHAR* Str, |
Construct from a buffer with extra slack on top of original string length. | ||
static FString ConstructWithSlack
(
const UTF32CHAR* Str, |
|||
static FString ConstructWithSlack
(
const ANSICHAR* Str, |
Construct from null-terminated C string with extra slack on top of original string length. | ||
static FString ConstructWithSlack
(
const UTF8CHAR* Str, |
|||
static FString ConstructWithSlack
(
const WIDECHAR* Str, |
|||
static FString ConstructWithSlack
(
const UCS2CHAR* Str, |
|||
| Takes an array of strings and removes any zero length entries. | |||
| Format the specified string using the specified arguments. | |||
| Format the specified string using the specified arguments. | |||
static FString FormatAsNumber
(
int32 InNumber |
Takes the number passed in and formats the string in comma format (12345 becomes "12,345") | ||
static FString FormatImpl
(
const ElementType* InFormatString, |
|||
static FString FormatImpl
(
const ElementType* InFormatString, |
|||
static FString FromBlob
(
const uint8* SrcBuffer, |
Converts a buffer to a string | ||
static FString FromHexBlob
(
const uint8* SrcBuffer, |
Converts a buffer to a string by hex-ifying the elements | ||
static FString FromInt
(
int32 Num |
Converts an integer to a string. | ||
static FString Join
(
const RangeType& Range, |
Joins a range of 'something that can be concatentated to strings with +=' together into a single string with separators. | ||
static FString JoinBy
(
const RangeType& Range, |
Joins a range of elements together into a single string with separators using a projection function. | ||
static FString Printf
(
UE::Core::TCheckedFormatString< FmtCharType, Types... > Fmt, |
Constructs a string similarly to how classic sprintf works. | ||
static FString PrintfImpl
(
const ElementType* Fmt, |
|||
static FString SanitizeFloat
(
double InFloat, |
Converts a float string with the trailing zeros stripped For example - 1.234 will be "1.234" rather than "1.234000" | ||
static bool ToBlob
(
const FString& Source, |
Converts a string into a buffer | ||
static bool ToHexBlob
(
const FString& Source, |
Converts a string into a buffer |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UE_FORCEINLINE_HINT const ElementType * operator*() |
Get pointer to the string | ||
FString & operator/=
(
const ElementType* Str |
Concatenate this path with given path ensuring the / character is used between them | ||
FString & operator/=
(
const CharType* Str |
Concatenate this path with given path ensuring the / character is used between them | ||
FString & operator/=
(
CharRangeType&& Str |
Concatenate this path with given path ensuring the / character is used between them | ||
const ElementType & operator[]
(
int32 Index |
Return specific const character from this string | ||
ElementType & operator[]
(
int32 Index |
Return specific character from this string | ||
FString & operator+=
(
AppendedCharType Char |
Append a single character and return a reference to this | ||
UE_FORCEINLINE_HINT auto operator+=
(
StrType&& Str |
Append a string and return a reference to this | ||
| End - intrusive TOptional |
|||
Deprecated Functions
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UE_ALLOWSHRINKING_BOOL_DEPRECATED
(
"RemoveAt" |
|||
UE_ALLOWSHRINKING_BOOL_DEPRECATED
(
"LeftInline" |
|||
UE_ALLOWSHRINKING_BOOL_DEPRECATED
(
"LeftChopInline" |
|||
UE_ALLOWSHRINKING_BOOL_DEPRECATED
(
"RightInline" |
|||
UE_ALLOWSHRINKING_BOOL_DEPRECATED
(
"RightChopInline" |
|||
UE_ALLOWSHRINKING_BOOL_DEPRECATED
(
"MidInline" |
|||
|
|||
|
|||
|
|||
|
|||
|
Construct from null-terminated C string or nullptr with extra slack on top of original string length | ||
|
Construct from null-terminated C substring or nullptr | ||
|
|||
|