TEXT adds L prefix

Why does the belove code work? When i just use the variables name, like if I put it like TEXT(LTchar) the compiler expect there to be a variable named LLTchar. What is going on?

void Example::Do(FString MeshPath) {
	const TCHAR* LTchar = *MeshPath;
	ConstructorHelpers::FObjectFinder<UStaticMesh> Path(TEXT(Tchar));
}

The Macro “TEXT” is expecting a parameter encapsulated within quotes:
TEXT(“Here is my text”)

I’ve run into the same issue many o’ times myself. The solution for me, has been to use various conversion macros.

I can’t recall which one specifically for your scenario, but play with the various options to replace TEXT:

  • TCHAR_TO_UTF8
  • UTF8_TO_TCHAR
  • TCHAR_TO_ANSI
  • ANSI_TO_TCHAR

For example:

 ConstructorHelpers::FObjectFinder<UStaticMesh> Path(TCHAR_TO_UTF8(LTchar));