Skip to content

FString Class

String literals should be defined using the TEXT() macro, which is a wrapper around the L prefix. It ensures that the literal is encoded using the native wide character encoding of the platform. The type can be accessed via the TCHAR macro.

There are three main types of strings in Unreal Engine:

FString

A general-purpose mutable wide character string. It is essentially similar to the standard C++ std::wstring type. The type also supports string formatting via two static methods; FString::Printf and FString::Format.

FString::Printf
FString TimeDesc = FString::Printf(TEXT("%02d:%02d"), NumMinutes, NumSeconds);
FString::Format with Ordered Args
TArray<FStringFormatArg> args;
args.Add(FStringFormatArg("Tim"));
args.Add(FStringFormatArg(450));
FString string = FString::Format(TEXT("Name = {0} Mana = {1}"), args);
FString::Format with Named Args
TMap<FString, FStringFormatArg> args;
args.Add(TEXT("Name"), FStringFormatArg("Tim"));
args.Add(TEXT("Mana"), FStringFormatArg(450));
FString string = FString::Format(TEXT("Name = {Name} Mana = {Mana}"), args);