FString

A dynamically sizeable string.

Windows
MacOS
Linux

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.

Constructors

Name Description

Public function

FString()

Public function

FString

(
    FString&&
)

Public function

FString

(
    const FString&
)

Public function

FString

(
    const CharType* Src
)

Constructor using an array of TCHAR

Public function

FString

(
    const FStringView& Other
)

Public function

FString

(
    const FString& Other,
    int32 ExtraSlack
)

Create a copy of the Other string with extra space for characters at the end of the string

Public function

FString

(
    FString&& Other,
    int32 ExtraSlack
)

Create a copy of the Other string with extra space for characters at the end of the string

Public function

FString

(
    int32 InCount,
    const CharType* InSrc
)

Constructor to create FString with specified number of characters from another string with additional character zero

Functions

Name Description

Public function

FString &

 

Append

(
    const CharType* Str,
    int32 Count
)

Append a string and return a reference to this

Public function

FString &

 

Append

(
    StrType&& Str
)

Append a string and return a reference to this

Public function

FString &

 

Append

(
    CharType* Str
)

Append a valid null-terminated string and return a reference to this

Public function

FString &

 

AppendChar

(
    TCHAR InChar
)

Append a single character and return a reference to this

Public function

void

 

AppendChars

(
    const UCS2CHAR* Str,
    int32 Count
)

Appends a character range without null-terminators in it

Public function

void

 

AppendChars

(
    const ANSICHAR* Str,
    int32 Count
)

Appends a character range without null-terminators in it

Public function

void

 

AppendChars

(
    const WIDECHAR* Str,
    int32 Count
)

Appends a character range without null-terminators in it

Public function

TEnableIf< T...

 

Appendf

(
    const FmtType& Fmt,
    Types... Args
)

Just like Printf, but appends the formatted text to the existing FString instead.

Public function

void

 

AppendInt

(
    int32 InNum
)

Appends the integer InNum to this string

Public function Const

DataType::Ra...

 

begin()

Public function

DataType::Ra...

 

begin()

DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support.

Public function Const

void

 

CheckInvariants()

Run slow checks on this string

Public function Static

FString

 

Chr

(
    TCHAR Ch
)

Returns a string containing only the Ch character

Public function Static

FString

 

ChrN

(
    int32 NumCharacters,
    TCHAR Char
)

Returns a string that is full of a variable number of characters

Public function Const

int32

 

Compare

(
    const FString& Other,
    ESearchCase::Type SearchCase
)

Lexicographically tests how this string compares to the Other given string

Public function Const

bool

 

Contains

(
    const FString& SubStr,
    ESearchCase::Type SearchCase,
    ESearchDir::Type SearchDir
)

Returns whether this string contains the specified substring.

Public function Const

bool

 

Contains

(
    const TCHAR* SubStr,
    ESearchCase::Type SearchCase,
    ESearchDir::Type SearchDir
)

Returns whether this string contains the specified substring.

Public function Const

FString

 

ConvertTabsToSpaces

(
    const int32 InSpacesPerTab
)

Replaces all instances of '' with TabWidth number of spaces

Public function

void

 

ConvertTabsToSpacesInline

(
    const int32 InSpacesPerTab
)

Replaces all instances of '' with TabWidth number of spaces

Public function Const

void

 

CountBytes

(
    FArchive& Ar
)

Public function Const

TConstIterat...

 

CreateConstIterator()

Creates a const iterator for the characters in this string

Public function

TIterator

 

CreateIterator()

Creates an iterator for the characters in this string

Public function Static

int32

 

CullArray

(
    TArray< FString >* InArray
)

Takes an array of strings and removes any zero length entries.

Public function

void

 

Empty

(
    int32 Slack
)

Create empty string of given size with zero terminating character

Public function Const

DataType::Ra...

 

end()

Public function

DataType::Ra...

 

end()

Public function Const

bool

 

EndsWith

(
    const FString& InSuffix,
    ESearchCase::Type SearchCase
)

Test whether this string ends with given string.

Public function Const

bool

 

EndsWith

(
    const TCHAR* InSuffix,
    ESearchCase::Type SearchCase
)

Test whether this string ends with given string.

Public function Const

bool

 

Equals

(
    const FString& Other,
    ESearchCase::Type SearchCase
)

Lexicographically tests whether this string is equivalent to the Other given string

Public function Const

int32

 

Find

(
    const TCHAR* SubStr,
    ESearchCase::Type SearchCase,
    ESearchDir::Type SearchDir,
    int32 StartPosition
)

Searches the string for a substring, and returns index into this string of the first found instance.

Public function Const

int32

 

Find

(
    const FString& SubStr,
    ESearchCase::Type SearchCase,
    ESearchDir::Type SearchDir,
    int32 StartPosition
)

Searches the string for a substring, and returns index into this string of the first found instance.

Public function Const

bool

 

FindChar

(
    TCHAR InChar,
    int32& Index
)

Searches the string for a character

Public function Const

bool

 

FindLastChar

(
    TCHAR InChar,
    int32& Index
)

Searches the string for the last occurrence of a character

Public function Const

int32

 

FindLastCharByPredicate

(
    Predicate Pred
)

Searches the string for the last occurrence of a character which matches the specified predicate.

Public function Const

int32

 

FindLastCharByPredicate

(
    Predicate Pred,
    int32 Count
)

Searches an initial substring for the last occurrence of a character which matches the specified predicate.

Public function Static

FString

 

Format

(
    const TCHAR* InFormatString,
    const FStringFormatNamedArguments&...
)

Format the specified string using the specified arguments.

Public function Static

FString

 

Format

(
    const TCHAR* InFormatString,
    const FStringFormatOrderedArguments...
)

Format the specified string using the specified arguments.

Public function Static

FString

 

FormatAsNumber

(
    int32 InNumber
)

Takes the number passed in and formats the string in comma format ( 12345 becomes "12,345")

Public function Static

FString

 

FromBlob

(
    const uint8* SrcBuffer,
    const uint32 SrcSize
)

Converts a buffer to a string

Public function Static

FString

 

FromHexBlob

(
    const uint8* SrcBuffer,
    const uint32 SrcSize
)

Converts a buffer to a string by hex-ifying the elements

Public function Static

FString

 

FromInt

(
    int32 Num
)

Converts an integer to a string.

Public function Const

SIZE_T

 

GetAllocatedSize()

Public function

DataType &

 

GetCharArray()

Get string as array of TCHARS

Public function Const

const DataTy...

 

GetCharArray()

Get string as const array of TCHARS

Public function

void

 

InsertAt

(
    int32 Index,
    TCHAR Character
)

Public function

void

 

InsertAt

(
    int32 Index,
    const FString& Characters
)

Public function Const

bool

 

IsEmpty()

Test whether this string is empty

Public function Const

bool

 

IsNumeric()

Returns true if the string only contains numeric characters

Public function Const

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).

Public function Static

FString

 

Join

(
    const RangeType& Range,
    const TCHAR* Separator
)

Joins a range of 'something that can be concatentated to strings with +=' together into a single string with separators.

Public function Static

FString

 

JoinBy

(
    const RangeType& Range,
    const TCHAR* Separator,
    ProjectionType Proj
)

Joins a range of elements together into a single string with separators using a projection function.

Public function

FString

 

Left

(
    int32 Count
)

Public function Const

FString

 

Left

(
    int32 Count
)

Returns the left most given number of characters

Public function

FString

 

LeftChop

(
    int32 Count
)

Public function Const

FString

 

LeftChop

(
    int32 Count
)

Returns the left most characters from the string chopping the given number of characters from the end

Public function

void

 

LeftChopInline

(
    int32 Count,
    bool bAllowShrinking
)

Modifies the string such that it is now the left most characters chopping the given number of characters from the end

Public function

void

 

LeftInline

(
    int32 Count,
    bool bAllowShrinking
)

Modifies the string such that it is now the left most given number of characters

Public function Const

FString

 

LeftPad

(
    int32 ChCount
)

Pad the left of this string for ChCount characters

Public function Const

int32

 

Len()

Get the length of the string, excluding terminating character

Public function Const

bool

 

MatchesWildcard

(
    const TCHAR* Wildcard,
    ESearchCase::Type SearchCase
)

Searches this string for a given wild card

This is a simple, SLOW routine. Use with caution

Public function Const

bool

 

MatchesWildcard

(
    const FString& Wildcard,
    ESearchCase::Type SearchCase
)

Searches this string for a given wild card

This is a simple, SLOW routine. Use with caution

Public function Const

FString

 

Mid

(
    int32 Start,
    int32 Count
)

Returns the substring from Start position for Count characters.

Public function

FString

 

Mid

(
    int32 Start,
    int32 Count
)

Public function

void

 

MidInline

(
    int32 Start,
    int32 Count,
    bool bAllowShrinking
)

Modifies the string such that it is now the substring from Start position for Count characters.

Public function Const

int32

 

ParseIntoArray

(
    TArray< FString >& OutArray,
    const TCHAR*const* DelimA...,
    int32 NumDelims,
    bool InCullEmpty
)

Breaks up a delimited string into elements of a string array, using the given delimiters

Public function Const

int32

 

ParseIntoArray

(
    TArray< FString >& OutArray,
    const TCHAR* pchDelim,
    bool InCullEmpty
)

Breaks up a delimited string into elements of a string array.

Public function Const

int32

 

ParseIntoArrayLines

(
    TArray< FString >& OutArray,
    bool InCullEmpty
)

Breaks up a delimited string into elements of a string array, using line ending characters

Public function Const

int32

 

ParseIntoArrayWS

(
    TArray< FString >& OutArray,
    const TCHAR* pchExtraDelim,
    bool InCullEmpty
)

Breaks up a delimited string into elements of a string array, using any whitespace and an optional extra delimter, like a ","

Public function

void

 

PathAppend

(
    const TCHAR* Str,
    int32 StrLength
)

Concatenate this path with given path ensuring the / character is used between them

Public function Static

TEnableIf< T...

 

Printf

(
    const FmtType& Fmt,
    Types... Args
)

Constructs FString object similarly to how classic sprintf works.

Public function

void

 

RemoveAt

(
    int32 Index,
    int32 Count,
    bool bAllowShrinking
)

Removes characters within the string.

Public function

bool

 

RemoveFromEnd

(
    const TCHAR* InSuffix,
    ESearchCase::Type SearchCase
)

Removes the text from the end of the string if it exists.

Public function

bool

 

RemoveFromEnd

(
    const FString& InSuffix,
    ESearchCase::Type SearchCase
)

Removes the text from the end of the string if it exists.

Public function

bool

 

RemoveFromStart

(
    const TCHAR* InPrefix,
    ESearchCase::Type SearchCase
)

Removes the text from the start of the string if it exists.

Public function

bool

 

RemoveFromStart

(
    const FString& InPrefix,
    ESearchCase::Type SearchCase
)

Removes the text from the start of the string if it exists.

Public function

void

 

RemoveSpacesInline()

Removes spaces from the string. I.E. "Spaces Are Cool" > "SpacesAreCool".

Public function Const

FString

 

Replace

(
    const TCHAR* From,
    const TCHAR* To,
    ESearchCase::Type SearchCase
)

Replace all occurrences of a substring in this string

Public function

void

 

ReplaceCharInline

(
    const TCHAR SearchChar,
    const TCHAR ReplacementChar,
    ESearchCase::Type SearchCase
)

Replace all occurrences of a character with another.

no dynamic allocation

Public function Const

FString

 

ReplaceCharWithEscapedChar

(
    const TArray< TCHAR >* Chars
)

Replaces certain characters with the "escaped" version of that character (i.e. replaces "\n" with "\n").

Public function Const

FString

 

ReplaceEscapedCharWithChar

(
    const TArray< TCHAR >* Chars
)

Removes the escape backslash for all supported characters, replacing the escape and character with the non-escaped version.

Public function

int32

 

ReplaceInline

(
    const TCHAR* SearchText,
    const TCHAR* ReplacementText,
    ESearchCase::Type SearchCase
)

Replace all occurrences of SearchText with ReplacementText in this string.

Public function Const

FString

 

ReplaceQuotesWithEscapedQuotes()

Returns a copy of this string with all quote marks escaped (unless the quote is already escaped)

Public function

void

 

Reserve

(
    int32 CharacterCount
)

To allow more efficient memory handling, automatically adds one for the string termination.

Public function

void

 

Reset

(
    int32 NewReservedSize
)

Empties the string, but doesn't change memory allocation, unless the new size is larger than the current string.

Public function Const

FString

 

Reverse()

Returns a copy of this string, with the characters in reverse order

Public function

void

 

ReverseString()

Reverses the order of characters in this string

Public function Const

FString

 

Right

(
    int32 Count
)

Returns the string to the right of the specified location, counting back from the right (end of the word).

Public function

FString

 

Right

(
    int32 Count
)

Public function Const

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).

Public function

FString

 

RightChop

(
    int32 Count
)

Public function

void

 

RightChopInline

(
    int32 Count,
    bool bAllowShrinking
)

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).

Public function

void

 

RightInline

(
    int32 Count,
    bool bAllowShrinking
)

Modifies the string such that it is now the right most given number of characters

Public function Const

FString

 

RightPad

(
    int32 ChCount
)

Pad the right of this string for ChCount characters

Public function Static

FString

 

SanitizeFloat

(
    double InFloat,
    const int32 InMinFractionalDigits
)

Converts a float string with the trailing zeros stripped For example - 1.234 will be "1.234" rather than "1.234000"

Public function Const

void

 

SerializeAsANSICharArray

(
    FArchive& Ar,
    int32 MinCharacters
)

Serializes a string as ANSI char array.

Public function

void

 

Shrink()

Remove unallocated empty character space from the end of this string

Public function Const

bool

 

Split

(
    const FString& InS,
    FString* LeftS,
    FString* RightS,
    ESearchCase::Type SearchCase,
    ESearchDir::Type SearchDir
)

Splits this string at given string position case sensitive.

Public function Const

bool

 

StartsWith

(
    const TCHAR* InSuffix,
    ESearchCase::Type SearchCase
)

Test whether this string starts with given string.

Public function Const

bool

 

StartsWith

(
    const FString& InPrefix,
    ESearchCase::Type SearchCase
)

Test whether this string starts with given string.

Public function Static

bool

 

ToBlob

(
    const FString& Source,
    uint8* DestBuffer,
    const uint32 DestSize
)

Converts a string into a buffer

Public function Const

bool

 

ToBool()

Converts a string into a boolean value 1, "True", "Yes", [FCoreTexts::True](API\Runtime\Core\FCoreTexts\True), [FCoreTexts::Yes](API\Runtime\Core\FCoreTexts\Yes), and non-zero integers become true 0, "False", "No", [FCoreTexts::False](API\Runtime\Core\FCoreTexts\False), [FCoreTexts::No](API\Runtime\Core\FCoreTexts\No), and unparsable values become false

Public function Static

bool

 

ToHexBlob

(
    const FString& Source,
    uint8* DestBuffer,
    const uint32 DestSize
)

Converts a string into a buffer

Public function Const

FString

 

ToLower()

Returns a new string with the characters of this converted to lowercase

Public function

FString

 

ToLower()

Converts all characters in this rvalue string to lowercase and moves it into the returned string.

Public function

void

 

ToLowerInline()

Converts all characters in this string to lowercase

Public function Const

FString

 

ToUpper()

Returns a new string with the characters of this converted to uppercase

Public function

FString

 

ToUpper()

Converts all characters in this rvalue string to uppercase and moves it into the returned string.

Public function

void

 

ToUpperInline()

Converts all characters in this string to uppercase

Public function Const

FString

 

TrimEnd()

Removes whitespace characters from the end of this string.

Public function

FString

 

TrimEnd()

Removes whitespace characters from the end of this string.

Public function

void

 

TrimEndInline()

Removes whitespace characters from the end of this string. Modifies the string in-place.

Public function

FString

 

TrimQuotes

(
    bool* bQuotesRemoved
)

Returns this string with wrapping quotation marks removed.

Public function Const

FString

 

TrimQuotes

(
    bool* bQuotesRemoved
)

Returns a copy of this string with wrapping quotation marks removed.

Public function

void

 

TrimQuotesInline

(
    bool* bQuotesRemoved
)

Trims wrapping quotation marks from this string.

Public function Const

FString

 

TrimStart()

Removes whitespace characters from the start of this string.

Public function

FString

 

TrimStart()

Removes whitespace characters from the start of this string.

Public function

FString

 

TrimStartAndEnd()

Removes whitespace characters from the start and end of this string.

Public function Const

FString

 

TrimStartAndEnd()

Removes whitespace characters from the start and end of this string.

Public function

void

 

TrimStartAndEndInline()

Removes whitespace characters from the start and end of this string. Modifies the string in-place.

Public function

void

 

TrimStartInline()

Removes whitespace characters from the start of this string. Modifies the string in-place.

Public function

void

 

TrimToNullTerminator()

Trims the inner array after the null terminator.

Operators

Name Description

Public function Const

 

operator FStringView()

Implicit conversion to a string view

Public function Const

const TCHAR ...

 

operator*()

Get pointer to the string

Pointer to Array of TCHAR if Num, otherwise the empty string

Public function

FString &

 

operator/=

(
    const TCHAR* Str
)

Concatenate this path with given path ensuring the / character is used between them

Public function

FString &

 

operator/=

(
    const FString& Str
)

Concatenate this path with given path ensuring the / character is used between them

Public function

TCHAR &

 

operator[]

(
    int32 Index
)

Return specific character from this string

Public function Const

const TCHAR ...

 

operator[]

(
    int32 Index
)

Return specific const character from this string

Public function

FString &

 

operator+=

(
    ANSICHAR Char
)

Append a single character and return a reference to this

Public function

FString &

 

operator+=

(
    UCS2CHAR Char
)

Public function

FString &

 

operator+=

(
    StrType&& Str
)

Append a string and return a reference to this

Public function

FString &

 

operator+=

(
    WIDECHAR Char
)

Public function

FString &

 

operator=

(
    const FStringView& Other
)

Copy assignment from a string view

Public function

FString &

 

operator=

(
    FString&&
)

Public function

FString &

 

operator=

(
    const FString&
)

Public function

FString &

 

operator=

(
    const TCHAR* Other
)

Copy Assignment from array of TCHAR

Typedefs

Name

Description

DataType

Array holding the character data

ElementType

TConstIterator

TIterator

Iterator typedefs

See Also

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss