Navigation
API > API/Runtime > API/Runtime/Core > API/Runtime/Core/Containers
Inheritance Hierarchy
References
| Module | Core |
| Header | /Engine/Source/Runtime/Core/Public/Containers/UnrealString.h |
| Include | #include "Containers/UnrealString.h" |
Syntax
class FString
Remarks
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 or escape sequences rather than to specify Unicode code points.
Constructors
| Type | Name | Description | |
|---|---|---|---|
FString () |
|||
| Create a copy of the Other string with extra space for characters at the end of the string | |||
FString
(
int32 Len, |
Construct from null-terminated C substring or nullptr | ||
FString
(
int32 Len, |
|||
FString
(
int32 Len, |
|||
FString
(
const ANSICHAR* Str, |
Construct from null-terminated C string or nullptr with extra slack on top of original string length | ||
FString
(
const WIDECHAR* Str, |
|||
FString
(
const UCS2CHAR* Str, |
|||
FString
(
CharRangeType&& Str, |
Construct from contiguous range of characters with extra slack on top of original string length | ||
FString
(
const ANSICHAR* Str |
Construct from null-terminated C string or nullptr | ||
FString
(
const WIDECHAR* Str |
|||
FString
(
const UCS2CHAR* Str |
|||
FString
(
CharRangeType&& Str |
Construct from contiguous range of characters such as FStringView or FStringBuilderBase | ||
| Create a copy of the Other string with extra space for characters at the end of the string |
Functions
| Type | Name | Description | |
|---|---|---|---|
| FString & | Append
(
const CharType* Str, |
Append a string and return a reference to this | |
| FString & | Append
(
CharRangeType&& Str |
Append a string and return a reference to this | |
| FString & | Append
(
CharType* Str |
Append a valid null-terminated string and return a reference to this | |
| FString & | AppendChar
(
TCHAR InChar |
Append a single character and return a reference to this | |
| void | AppendChars
(
const WIDECHAR* Str, |
Appends a character range without null-terminators in it | |
| void | AppendChars
(
const ANSICHAR* Str, |
Appends a character range without null-terminators in it | |
| void | AppendChars
(
const UCS2CHAR* Str, |
Appends a character range without null-terminators in it | |
| void | AppendChars
(
const UTF8CHAR* Str, |
Appends a character range without null-terminators in it | |
| FString & | Appendf
(
const FmtType& Fmt, |
Just like Printf, but appends the formatted text to the existing FString instead. | |
| void | AppendInt
(
int32 InNum |
Appends the integer InNum to this string | |
| DataType::RangedForIteratorType | begin () |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. | |
| DataType::RangedForConstIteratorType | begin () |
||
| void | Run slow checks on this string | ||
| FString | Chr
(
TCHAR Ch |
Returns a string containing only the Ch character | |
| FString | ChrN
(
int32 NumCharacters, |
Returns a string that is full of a variable number of characters | |
| int32 | Compare
(
const FString& Other, |
Lexicographically tests how this string compares to the Other given string | |
| bool | Contains
(
const TCHAR* SubStr, |
Returns whether this string contains the specified substring. | |
| bool | Contains
(
const FString& SubStr, |
Returns whether this string contains the specified substring. | |
| bool | Contains
(
const TCHAR* SubStr, |
Returns whether this string contains the specified substring. | |
| bool | Contains
(
TCharRangeType&& SubStr, |
Returns whether this string contains the specified substring. | |
| FString | ConvertTabsToSpaces
(
const int32 InSpacesPerTab |
Replaces all instances of '' with TabWidth number of spaces | |
| FString | ConvertTabsToSpaces
(
const int32 InSpacesPerTab |
Replaces all instances of '' with TabWidth number of spaces | |
| void | ConvertTabsToSpacesInline
(
const int32 InSpacesPerTab |
Replaces all instances of '' with TabWidth number of spaces | |
| void | CountBytes
(
FArchive& Ar |
||
| TConstIterator | Creates a const iterator for the characters in this string | ||
| TIterator | Creates an iterator for the characters in this string | ||
| int32 | Takes an array of strings and removes any zero length entries. | ||
| void | Empty () |
Create empty string of given size with zero terminating character | |
| void | Empty
(
int32 Slack |
Create empty string of given size with zero terminating character | |
| DataType::RangedForIteratorType | end () |
||
| DataType::RangedForConstIteratorType | end () |
||
| bool | EndsWith
(
TCharRangeType&& InSuffix, |
Test whether this string ends with given suffix. | |
| bool | EndsWith
(
const TCHAR* 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 TCHAR* 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
(
const TCHAR* SubStr, |
Searches the string for a substring, and returns index into this string of the first found instance. | |
| int32 | Find
(
TCharRangeType&& SubStr, |
Searches the string for a substring, and returns index into this string of the first found instance. | |
| int32 | Find
(
const TCHAR* SubStr, |
Searches the string for a substring, and returns index into this string of the first found instance. | |
| int32 | Find
(
const FString& SubStr, |
Searches the string for a substring, and returns index into this string of the first found instance. | |
| bool | FindChar
(
TCHAR InChar, |
Searches the string for a character | |
| bool | FindLastChar
(
TCHAR InChar, |
Searches the string for the last occurrence of a character | |
| int32 | FindLastCharByPredicate
(
Predicate Pred, |
Searches an initial substring for the last occurrence of a character which matches the specified predicate. | |
| int32 | FindLastCharByPredicate
(
Predicate Pred |
Searches the string for the last occurrence of a character which matches the specified predicate. | |
| FString | Format
(
const TCHAR* InFormatString, |
Format the specified string using the specified arguments. | |
| FString | Format
(
const TCHAR* InFormatString, |
Format the specified string using the specified arguments. | |
| FString | FormatAsNumber
(
int32 InNumber |
Takes the number passed in and formats the string in comma format ( 12345 becomes "12,345") | |
| FString | FromBlob
(
const uint8* SrcBuffer, |
Converts a buffer to a string | |
| FString | FromHexBlob
(
const uint8* SrcBuffer, |
Converts a buffer to a string by hex-ifying the elements | |
| FString | FromInt
(
int32 Num |
Converts an integer to a string. | |
| SIZE_T | |||
| DataType & | GetCharArray () |
Get string as array of TCHARS | |
| const DataType & | GetCharArray () |
Get string as const array of TCHARS | |
| void | InsertAt
(
int32 Index, |
||
| void | |||
| bool | IsEmpty () |
Test whether this string is empty | |
| bool | IsNumeric () |
Returns true if the string only contains numeric characters | |
| 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). | |
| FString | Join
(
const RangeType& Range, |
Joins a range of 'something that can be concatentated to strings with +=' together into a single string with separators. | |
| FString | JoinBy
(
const RangeType& Range, |
Joins a range of elements together into a single string with separators using a projection function. | |
| FString | Left
(
int32 Count |
||
| FString | Left
(
int32 Count |
Returns the left most given number of characters | |
| FString | LeftChop
(
int32 Count |
||
| FString | LeftChop
(
int32 Count |
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 | |
| int32 | 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 TCHAR* Wildcard, |
Searches this string for a given wild cardThis is a simple, SLOW routine. Use with caution | |
| bool | MatchesWildcard
(
TCharRangeType&& Wildcard, |
Searches this string for a given wild cardThis is a simple, SLOW routine. Use with caution | |
| bool | MatchesWildcard
(
const TCHAR* Wildcard, |
Searches this string for a given wild cardThis is a simple, SLOW routine. Use with caution | |
| FString | Mid
(
int32 Start, |
||
| FString | Mid
(
int32 Start |
Returns the substring from Start position to the end | |
| FString | Mid
(
int32 Start |
||
| FString | Mid
(
int32 Start, |
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. | |
| 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 TCHAR* Str, |
Concatenate this path with given path ensuring the / character is used between them | |
| FString | Printf
(
const FmtType& Fmt, |
Constructs FString object similarly to how classic sprintf works. | |
| DataType::RangedForConstReverseIteratorType | rbegin () |
||
| DataType::RangedForReverseIteratorType | rbegin () |
||
| void | RemoveAt
(
int32 Index, |
Removes characters within the string. | |
| bool | RemoveFromEnd
(
const TCHAR* 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 TCHAR* InSuffix, |
Removes the text from the end of the string if it exists. | |
| bool | RemoveFromEnd
(
TCharRangeType&& InSuffix, |
Removes the text from the end of the string if it exists. | |
| bool | RemoveFromStart
(
TCharRangeType&& InPrefix, |
Removes the text from the start of the string if it exists. | |
| bool | RemoveFromStart
(
const TCHAR* InPrefix, |
Removes the text from the start 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
(
const TCHAR* InPrefix, |
Removes the text from the start of the string if it exists. | |
| void | Removes spaces from the string. I.E. "Spaces Are Cool" > "SpacesAreCool". | ||
| DataType::RangedForReverseIteratorType | rend () |
||
| DataType::RangedForConstReverseIteratorType | rend () |
||
| FString | Replace
(
const TCHAR* From, |
Replace all occurrences of a substring in this string | |
| FString | Replace
(
const TCHAR* From, |
Replace all occurrences of a substring in this string | |
| void | ReplaceCharInline
(
const TCHAR SearchChar, |
Replace all occurrences of a character with another.no dynamic allocation | |
| FString | ReplaceCharWithEscapedChar
(
const TArray< TCHAR >* Chars |
Replaces certain characters with the "escaped" version of that character (i.e. replaces "\n" with "\n"). | |
| FString | ReplaceCharWithEscapedChar
(
const TArray< TCHAR >* Chars |
Replaces certain characters with the "escaped" version of that character (i.e. replaces "\n" with "\n"). | |
| void | ReplaceCharWithEscapedCharInline
(
const TArray< TCHAR >* Chars |
Replaces certain characters with the "escaped" version of that character (i.e. replaces "\n" with "\n"). | |
| FString | ReplaceEscapedCharWithChar
(
const TArray< TCHAR >* Chars |
Removes the escape backslash for all supported characters, replacing the escape and character with the non-escaped version. | |
| FString | ReplaceEscapedCharWithChar
(
const TArray< TCHAR >* Chars |
Removes the escape backslash for all supported characters, replacing the escape and character with the non-escaped version. | |
| void | ReplaceEscapedCharWithCharInline
(
const TArray< TCHAR >* Chars |
Removes the escape backslash for all supported characters, replacing the escape and character with the non-escaped version. | |
| int32 | ReplaceInline
(
const TCHAR* SearchText, |
Replace all occurrences of SearchText with ReplacementText in this string. | |
| FString | Returns a copy of this string with all quote marks escaped (unless the quote is already escaped) | ||
| FString | 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. | |
| FString | Reverse () |
Returns a copy of this string, with the characters in reverse order | |
| FString | Reverse () |
Returns this string, with the characters in reverse order | |
| void | Reverses the order of characters in this string | ||
| FString | Right
(
int32 Count |
Returns the string to the right of the specified location, counting back from the right (end of the word). | |
| FString | Right
(
int32 Count |
||
| FString | RightChop
(
int32 Count |
Returns the string to the right of the specified location, counting forward from the left (from the beginning of the word). | |
| FString | RightChop
(
int32 Count |
||
| 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 | |
| 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" | |
| 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& InS, |
Splits this string at given string position case sensitive. | |
| bool | Split with ESearchCase::IgnoreCase and ESearchDir::FromStart. | ||
| bool | StartsWith
(
const FString& InPrefix, |
Test whether this string starts with given prefix. | |
| bool | StartsWith
(
const TCHAR* InPrefix, |
Test whether this string starts with given prefix. | |
| bool | StartsWith
(
const TCHAR* InPrefix, |
Test whether this string starts with given prefix. | |
| bool | StartsWith
(
TCharRangeType&& InPrefix, |
Test whether this string starts with given prefix. | |
| bool | Converts a string into a buffer | ||
| 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 | |
| bool | Converts a string into a buffer | ||
| FString | ToLower () |
Returns a new string with the characters of this converted to lowercase | |
| FString | ToLower () |
Converts all characters in this rvalue string to lowercase and moves it into the returned string. | |
| void | Converts all characters in this string to lowercase | ||
| FString | ToUpper () |
Returns a new string with the characters of this converted to uppercase | |
| FString | ToUpper () |
Converts all characters in this rvalue string to uppercase and moves it into the returned string. | |
| void | Converts all characters in this string to uppercase | ||
| FString | TrimChar
(
const TCHAR CharacterToTrim, |
Returns a copy of this string with wrapping CharacterToTrim removed (removes at max one instance in the beginning and end of the string). | |
| FString | TrimChar
(
const TCHAR CharacterToTrim, |
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
(
const TCHAR 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). | |
| FString | TrimEnd () |
Removes whitespace characters from the end of this string. | |
| FString | TrimEnd () |
Removes whitespace characters from the end of this string. | |
| void | 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. | |
| FString | TrimStart () |
Removes whitespace characters from the start of this string. | |
| FString | TrimStart () |
Removes whitespace characters from the start of this string. | |
| FString | Removes whitespace characters from the start and end of this string. | ||
| FString | Removes whitespace characters from the start and end of this string. | ||
| void | Removes whitespace characters from the start and end of this string. Modifies the string in-place. | ||
| void | Removes whitespace characters from the start of this string. Modifies the string in-place. | ||
| void | Trims the inner array after the null terminator. |
Operators
| Type | Name | Description | |
|---|---|---|---|
| bool | operator!=
(
const FString& Rhs |
Lexicographically test whether the left string is != the right stringcase insensitive | |
| bool | operator!=
(
const CharType* Rhs |
Lexicographically test whether the left string is != the right stringcase insensitive | |
| const TCHAR * | operator* () |
Get pointer to the stringPointer to Array of TCHAR if Num, otherwise the empty string | |
| FString & | operator/=
(
CharRangeType&& 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/=
(
const TCHAR* Str |
Concatenate this path with given path ensuring the / character is used between them | |
| const TCHAR & | operator[]
(
int32 Index |
Return specific const character from this string | |
| TCHAR & | operator[]
(
int32 Index |
Return specific character from this string | |
| FString & | operator+=
(
AppendedCharType Char |
Append a single character and return a reference to this | |
| auto | operator+=
(
StrType&& Str |
Append a string and return a reference to this | |
| FString & | operator=
(
CharRangeType&& Range |
||
| FString & | operator=
(
const TCHAR* Str |
||
| FString & | |||
| FString & | |||
| bool | operator==
(
const CharType* Rhs |
Lexicographically test whether the left string is == the right stringcase insensitive | |
| bool | operator==
(
const FString& Rhs |
Lexicographically test whether the left string is == the right stringcase insensitive |
Typedefs
| Name | Description |
|---|---|
| AllocatorType | |
| DataType | Array holding the character data |
| ElementType | |
| TConstIterator | |
| TIsCharRangeNotCArray | Trait testing whether a type is a contiguous range of characters, and not CharType[]. |
| TIsCharRangeNotCArrayNotFString | Trait testing whether a type is a contiguous range of characters, and not CharType[] and not FString. |
| TIsTCharRangeNotCArray | Trait testing whether a type is a contiguous range of TCHAR, and not TCHAR[]. |
| TIsTCharRangeNotCArrayNotFString | Trait testing whether a type is a contiguous range of TCHAR, and not TCHAR[] and not FString. |
| TIterator | Iterator typedefs |
| TRangeElementType |
See Also
https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/StringHandling/FString/