Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Compare String representations in Unreal

Unreal supports many different string utilities, such as ANSICHAR, TCHAR, FString, FName, FCString, etc. Beside reading endless API documentations, is there a high level overview that summaries all these types? 1. How to decide which one to use. 2. Advantages and disadvantages among these strings. 3. Any other string representations?

Product Version: UE 4.7
more ▼

asked May 24 '15 at 12:39 AM in C++ Programming

avatar image

20 3 5 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hello, KidBroker

If you need to use string manipulation, such as case changing, excerpting substrings, reversing, searching and comparing, please use FString. The main disatvange of this type is that availability of this functionality makes it more expensive than the immutable string classes.

FCString is a typedef inside of TCString class for TCHAR strings. TCString class provides a set of widely used utility functions that operate on plain C strings. There are also specialized implementations for ANSICHAR and WIDECHAR strings in TCString:

 typedef TCString<TCHAR>    FCString;
 typedef TCString<ANSICHAR> FCStringAnsi;
 typedef TCString<WIDECHAR>  FCStringWide;

FNames represent public names, available to the world. They provide a very lightweight system for using strings, where a given string is stored only once in a data table, even if it is reused. Please note that FNames are case-insensitive. They are immutable and cannot be manipulated. The storage system and static nature of FNames means that it is fast to look up and access FNames with keys. Another feature of the FName subsystem is the use of a hash table to provide fast string to FName conversions. This type should be used when you save strings to hard drive or send them over the network since FName minimizes data storage and data transfer operations.

FText represents a "display string". Any text you want to display to the user should be handled with FText. The FText class has built-in support for localization, and can handle text content that is localized and stored in a lookup table, as well as text that is localized at runtime, such as numbers, dates, times, and formatted text. Even text that does not need to be localized can be handled with FText. This includes user-entered content such as a player's name, and any text displayed with Slate. FText does not offer any mutation functions, because making changes to display strings is a very unsafe operation.

In terms of size, please note that FText is 40 bytes, FString is 16 bytes and FName is only 8 bytes.

Thus, to sum up, you use FStrings if you need to manipulate a string, for example when building a URL or creating a save file name. FNames are good for asset names and material parameters. Finally, FText is used for HUD text, player names and calendar dates.

Hope this helped!

Have a great day!

more ▼

answered May 25 '15 at 09:57 AM

avatar image

Andrii Melnyk
1.9k 60 20 112

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question