Download

Strings and Macros - Guides and Background?

Hi,

I struggle a bit when it comes to Strings (FString, FName, FText, TCHAR, wchar_t) and related macros ( TEXT() ) in Unreal.
I red the Documentations but they are split up in multiple sites and I still don’t get some things…
So I guess my problem is my Base C++ Knowledge when it comes to strings,because I never had to dive deeper into the encoding and OS topics for my applications.

So could someone give me a beginner friendly background guide please?

I understand that I should use FText for all ingame displayed stuff
and FName is only for assets or bone identifiers and so on
and FString is just for internal non localisation use

But why do I have to use the TEXT macro on all of them?
And what does it do exactly…
The engine source says:


L ## x

What does L mean?

So is


L"My Text"

a TCHAR* ?

Because when I use:


UE_LOG(LogTemp, Warning, TEXT("Oh ooohhh %s", *actor->GetName()))

I have to use the * overload on FString to an TCHAR*

So most of my confusion comes from the TCHAR, wchar_t stuff which I know nothing about… And why doesn’t the Print, Log and Display macros or functions in ue4 use this base stuff and not the ‘F____’ ones?
What is this stuff all about?

Depending on the platform, UE4 defines a different size for “TCHAR”.
“TEXT” macro is just easy way to avoid mistakes and make code more readable.

Most of the weirdness you see is pretty much always for the sake of multiplatform compatibility.